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:
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))