eriklindernoren / Keras-GAN

Keras implementations of Generative Adversarial Networks.
MIT License
9.19k stars 3.14k forks source link

SRGAN: ValueError: Input 0 of layer fc1 is incompatible with the layer: expected axis -1 of input shape to have value 25088 but received input with shape [None, 32768] #235

Open protoneqt opened 4 years ago

protoneqt commented 4 years ago

When I run srgan.py, I have the following error:

WARNING:tensorflow:Model was constructed with shape (None, 224, 224, 3) for input Tensor("input_1:0", shape=(None, 224, 224, 3), dtype=float32), but it was called on an input with incompatible shape (None, 256, 256, 3).
Traceback (most recent call last):
  File "E:/home/projects/deblur/git/Keras-GAN/srgan/srgan.py", line 272, in <module>
    gan = SRGAN()
  File "E:/home/projects/deblur/git/Keras-GAN/srgan/srgan.py", line 51, in __init__
    self.vgg = self.build_vgg()
  File "E:/home/projects/deblur/git/Keras-GAN/srgan/srgan.py", line 114, in build_vgg
    img_features = vgg(img)
  File "E:\home\projects\main\git\enp\venv2\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 922, in __call__
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "E:\home\projects\main\git\enp\venv2\lib\site-packages\tensorflow\python\keras\engine\network.py", line 719, in call
    convert_kwargs_to_constants=base_layer_utils.call_context().saving)
  File "E:\home\projects\main\git\enp\venv2\lib\site-packages\tensorflow\python\keras\engine\network.py", line 888, in _run_internal_graph
    output_tensors = layer(computed_tensors, **kwargs)
  File "E:\home\projects\main\git\enp\venv2\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 886, in __call__
    self.name)
  File "E:\home\projects\main\git\enp\venv2\lib\site-packages\tensorflow\python\keras\engine\input_spec.py", line 216, in assert_input_compatibility
    ' but received input with shape ' + str(shape))
ValueError: Input 0 of layer fc1 is incompatible with the layer: expected axis -1 of input shape to have value 25088 but received input with shape [None, 32768]

Process finished with exit code 1
lbj96347 commented 4 years ago

Well, I met the same issue with you. I thought it was caused by incompatible versions of Keras & Tensorflow. I used to use the latest version of tensorflow on macOS, the same error message came out.

I reinstalled Keras==2.0.6 & Tensorflow==1.15.0, it works fine now.

Hope it could help you.