AttributeError: 'Sequential' object has no attribute 'model'
See original GitHub issueEnvironment: Anaconda 5.1, Python 3.6, Ubuntu 16.04
Ran code under the following versions separately: a) Tensorflow is 1.8. Using tensorflow.python.keras.
b) Standalone package. keras.version: 2.1.6
The code runs on Keras (keras.version: 2.1.6), but when I ran it under tensorflow.python.keras package, I got this error:
This is the model generator: `# Model definition
def create_model0():
model = Sequential()
model.add(Dense(16, input_shape=(X_train_seq.shape[1],)))
model.add(Dense(1)) # default activation is linear
model.compile(optimizer=“Adam”, loss=“mean_squared_error”, metrics=[“mse”, “mae”])
return model
`
Here is the code causing the error when using Tensorflow version 1.8. and tensorflow.python.keras: `#create model
model0 = create_model0() print(model0.summary()) #temp disabled for now. SVG(model_to_dot(model0).create(prog=‘dot’, format=‘svg’))`
Here is the error: `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-115-06504b17a5bd> in <module>() 4 5 #temp disabled for now. ----> 6 SVG(model_to_dot(model0).create(prog=‘dot’, format=‘svg’)) 7 # ~/anaconda3/envs/tflowpy36a51/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/utils/vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir) 8 # 80 if not model.built:
~/anaconda3/envs/tflowpy36a51/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/utils/vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir) 80 if not model.built: 81 model.build() —> 82 model = model.model 83 layers = model.layers 84
AttributeError: ‘Sequential’ object has no attribute ‘model’`
Note: I have manually inserted export for model_to_dot() when using tensorflow.python.keras package.
I thought the Keras package inside Tensorflow is the same as the standalone Keras. But it looks like it is not! Correct?
What is causing this error when using tensorflow.python only? Repeat: No such error when using standalone keras.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
pip install tensorflow
orpip install keras
should get you the most stable version of each release, e.g.tensorflow==1.8.0
orkeras==2.1.6
.That being said, the plotting fix isn’t released in an official release yet.
When
TensorFlow
ported the Keras API, they got rid of some of the deprecated things, such asmodels.models
in Sequential API. However, the plotting was not hit with a test.not yet for the GPU, because Tensorflow-GPU was not generating consistent results by all means
I’ll do as soon as possible if I had time