While building a model using:
model = Model(inputs=[input_text], outputs=pred)
getting an error:
AttributeError: 'Tensor' object has no attribute '_keras_shape'
The complete notebook that I tried can be found here... https://github.com/shantanuo/pandas_examples/blob/master/tensorflow/tf_learn.ipynb
And the same code in plain text here... https://gist.github.com/shantanuo/4e35baba144ee658e4dd4d1f87e19f3a
I will like to know why am I getting an error even if I am using the exact same code as shown in this blog:
https://towardsdatascience.com/transfer-learning-using-elmo-embedding-c4a7e415103c
The expected output - something like this:
The model summary is: _________________________________________________________________ Layer (type) Output Shape Param #
================================================================= input_2 (InputLayer) (None, 1) 0
_________________________________________________________________ lambda_2 (Lambda) (None, 1024) 0
_________________________________________________________________ dense_3 (Dense) (None, 256) 262400
_________________________________________________________________ dense_4 (Dense) (None, 1) 257
I tried to upgrade tensorflow and keras but getting the same error:
!pip install --upgrade tensorflow
Tensor object has no attribute keras_shape Ask Question Asked2 years, 11 months ago Active2 years, 2 months ago Viewed13k times 12 While building a model using: model = Model(inputs=[input_text], outputs=pred) getting an error:
'Tensor' object has no attribute 'is_initialized' when using tensorflow.keras.backend.shape 10 Tensorboard AttributeError: 'ModelCheckpoint' object has no attribute 'on_train_batch_begin'
This layer wraps a callable object for use as a Keras layer. The callable object can be passed directly, or be specified by a Python string with a handle that gets passed to hub.load (). This is the preferred API to load a TF2-style SavedModel from TF Hub into a Keras model. Calling this function requires TF 1.15 or newer.
Depending on the version of tensorflow/keras the attribute names can differ. I hope it helps. Ping me if this doesn't solve the problem. Sorry, something went wrong.
I had a similar issue when I changed my computer with a different tensorflow version.
What solved it for me was using .shape instead of ._keras_shape
Depending on the version of tensorflow/keras and/or how you import them (from keras, from tensorflow.keras or from tensorflow.python.keras) it appears that the attributes names can differ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With