question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'Sequential' object has no attribute 'model'

See original GitHub issue

Environment: 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:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
brge17commented, May 31, 2018

pip install tensorflow or pip install keras should get you the most stable version of each release, e.g. tensorflow==1.8.0 or keras==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 as models.models in Sequential API. However, the plotting was not hit with a test.

1reaction
MyVanitarcommented, Jun 8, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Sequential' object has no attribute 'model'
For solving your error you can go through the below steps: 1. Install dependency for can run the env : !pip install Box2D0...
Read more >
attributeerror: 'sequential' object has no attribute 'model'
AttributeError : 'Sequential' object has no attribute 'model'` Note: I have manually inserted export for model_to_dot() when using tensorflow.python.keras ...
Read more >
'Sequential' object has no attribute 'predict_classes' ( Solved )
This attributeError comes when there is no module predict_classes provided by the Keras packages. The other reason could be that you are using...
Read more >
'Sequential' object has no attribute 'predict_classes'
Hello All, I'm trying to run my model but facing "'Sequential' object has no attribute 'predict_classes' " I have Name: tensorflow Version: ...
Read more >
AttributeError: 'Sequential' object has no attribute 'shape'
Getting error AttributeError: 'Sequential' object has no attribute 'shape' After below code model <- keras_model_sequential() model ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found