keras-adversarial icon indicating copy to clipboard operation
keras-adversarial copied to clipboard

AttributeError: 'Model' object has no attribute 'internal_input_shapes'

Open leovan opened this issue 7 years ago • 11 comments

I am using Python 3.6 and install keras_adversarial with the master branch, it seems that Model has no attribute 'internal_input_shapes' BUT '_internal_input_shapes'. Also Model has no attribute 'internal_output_shapes' either.

Traceback (most recent call last): File "example_gan.py", line 118, in main() File "example_gan.py", line 114, in main latent_dim=latent_dim) File "example_gan.py", line 71, in example_gan loss=loss) File "/Users/leo/Applications/anaconda3/lib/python3.6/site-packages/keras_adversarial-0.0.3-py3.6.egg/keras_adversarial/adversarial_model.py", line 91, in adversarial_compile AttributeError: 'Model' object has no attribute 'internal_input_shapes'

leovan avatar Jan 29 '18 13:01 leovan

After I correct the 'internal_input_shapes' and 'internal_output_shapes' to '_internal_input_shapes' and '_internal_output_shapes', it still got errors with example_gan.py:

Traceback (most recent call last): File "example_gan.py", line 118, in main() File "example_gan.py", line 114, in main latent_dim=latent_dim) File "example_gan.py", line 90, in example_gan batch_size=32) File "/Users/leo/Applications/anaconda3/lib/python3.6/site-packages/keras_adversarial-0.0.3-py3.6.egg/keras_adversarial/legacy.py", line 18, in fit File "/Users/leo/Applications/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1593, in fit batch_size=batch_size) File "/Users/leo/Applications/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1426, in _standardize_user_data exception_prefix='input') File "/Users/leo/Applications/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 110, in _standardize_input_data 'with shape ' + str(data_shape)) ValueError: Error when checking input: expected discriminator_flatten_input to have 2 dimensions, but got array with shape (60000, 28, 28)

I am using Python 3.6, Keras 2.1.3 and Tensorflow 1.5

leovan avatar Jan 29 '18 15:01 leovan

I also have the same problems

ilansc avatar Feb 12 '18 13:02 ilansc

I'm stuck in the same situation. Any update?

I had the same error and on Keras 2.1.3, I tried downgrade keras to 2.1.2 and it works. So this maybe a temp solution.

kechan avatar Feb 26 '18 17:02 kechan

same with 2.1.4 only 2.1.2 works

innovia avatar Feb 27 '18 08:02 innovia

The first error appears to have happened because of a change in Keras, internal_input_shapes and internal_output_shapes were changed to be private variables in the keras/engine/topology.py file, reference this commit

As far as a fix for the second error goes, I'm still not sure. But the example_gan.py file is running a legacy version of fit, and I'm not sure what ought to be done to fix it.

MitchProbst avatar Feb 28 '18 19:02 MitchProbst

I have same problem with Keras 2.1.3 on one machine but works fine with Keras 2.1.2 on other machine. I might need to downgrade 2.1.3 to 2.1.2.

mohbattharani avatar Apr 05 '18 04:04 mohbattharani

my keras version was 2.1.6 and i was getting the same error.... downgrading solved the issue

adibyte95 avatar Jul 21 '18 07:07 adibyte95

do you have any suggestions about how to use the keras-adversarial examples without downgrading the keras, i.e. with newer versions?

csapot avatar Sep 24 '18 08:09 csapot

with newer keras versions try K.int_shape(model.inputs[0])

SarahMue avatar Feb 12 '19 19:02 SarahMue

with newer keras versions try K.int_shape(model.inputs[0])

Where to use this?

Ritaprava95 avatar Oct 24 '19 14:10 Ritaprava95