# Loading saved tensorflow model

**URL:** <https://discuss.ai.google.dev/t/loading-saved-tensorflow-model/27250>\
**Category:** General Discussion\
**Tags:** keras, models, help\_request\
**Created:** [November 26, 2021, 4:37am UTC](https://discuss.ai.google.dev/t/loading-saved-tensorflow-model/27250 "2021-11-26T04:37:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parvez\_Sohail](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/parvez_sohail/32/9807_2.png) [@Parvez\_Sohail](https://discuss.ai.google.dev/u/Parvez_Sohail)\
**Post date:** [November 26, 2021, 4:37am UTC](https://discuss.ai.google.dev/t/loading-saved-tensorflow-model/27250/1 "2021-11-26T04:37:01Z")

</div>

I am working on a project **“News Classification”**. Where the model has to classify(multi-class classification problem) a given text into **business, entertainment, politics, sport and tech.**

I am using **TensorFlow==2.7.0** on **Google Colab**. I had trained 7 different models. After, training and made prediction on it. When compared to all models, _Conv1d_ performed the best. The best performing model saved `model_2.save('saved_model/my_model')`.It has done well till here.

But, When I want to load the saved model using the code

`loaded_model = tf.keras.models.load_model('saved_model/my_model')` then, I am getting the below exception:

```auto
TypeError Traceback (most recent call last)
<ipython-input-129-c92edaf0db7f> in <module>()
----> 1 load_model = tf.keras.models.load_model('saved_model/my_model')
      2 # load_model.preditct(val_sentences)

1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape, allow_broadcast)
    547 str_values = [compat.as_bytes(x) for x in proto_values]
    548 except TypeError:
--> 549 raise TypeError(f"Failed to convert elements of {values} to Tensor. "
    550 "Consider casting elements to a supported type. See "
    551 "https://www.tensorflow.org/api_docs/python/tf/dtypes "

TypeError: Exception encountered when calling layer "conv1d" (type Conv1D).

Failed to convert elements of tf.RaggedTensor(values=tf.RaggedTensor(values=Tensor("Placeholder:0", shape=(None, 128), dtype=float32), row_splits=Tensor("Placeholder_1:0", shape=(None,), dtype=int64)), row_splits=Tensor("conv1d/Conv1D/RaggedExpandDims/RaggedFromUniformRowLength/RowPartitionFromUniformRowLength/mul:0", shape=(None,), dtype=int64)) to Tensor. Consider casting elements to a supported type. See https://www.tensorflow.org/api_docs/python/tf/dtypes for supported TF dtypes.

Call arguments received:
  • inputs=tf.RaggedTensor(values=Tensor("Placeholder:0", shape=(None, 128), dtype=float32), row_splits=Tensor("Placeholder_1:0", shape=(None,), dtype=int64))

```

---

<div class="post-metadata">

**Author:** ![Bhack](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/bhack/32/6388_2.png) [@Bhack](https://discuss.ai.google.dev/u/Bhack)\
**Post date:** [November 26, 2021, 3:46pm UTC](https://discuss.ai.google.dev/t/loading-saved-tensorflow-model/27250/3 "2021-11-26T15:46:48Z")

</div>

Have you already checked:

[https://github.com/tensorflow/tensorflow/issues/42320](https://github.com/tensorflow/tensorflow/issues/42320)
