keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.92k stars 19.45k forks source link

[Bug Request] InvalidArgumentError: Incompatible shapes When I try to use accuracy as metric. #13484

Closed jmpr0 closed 3 years ago

jmpr0 commented 5 years ago

This code: https://github.com/keras-team/keras-contrib/blob/master/examples/improved_wgan.py

Hi guys. When I try to train_on_batch my model, keras raise subsequent exception:

InvalidArgumentError:  Incompatible shapes: [2500,1] vs. [50,1]
     [[node metrics_7/model_16_accuracy_2/Equal (defined at /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1751) ]] [Op:__inference_keras_scratch_graph_6318]

Function call stack:
keras_scratch_graph

The error derive from the use of 'accuracy' metric, and goes away when I remove it. But, how I can solve it?

Thanks.

Terkea commented 4 years ago

I got just the same issue, Windows 10, Tf 2, Python 3


InvalidArgumentError:  Incompatible shapes: [32] vs. [32,111,111]
     [[node metrics/accuracy/Equal (defined at <ipython-input-40-01a7b3e6c0fd>:12) ]] [Op:__inference_distributed_function_3107]

Function call stack:
distributed_function```
Manish-Moond commented 3 years ago

I got same error when i am using CNN. (Windows 10 Tf 2.1, python 3) because i didn't use Flatten() layer after CNN layers()