tensorflow: tf.keras.metrics.MeanIoU have some conflicts with sparse_categorical_crossentropy
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
- TensorFlow installed from (source or binary): source
- TensorFlow version (use command below): 2.0 RC
- Python version: 3.6
- CUDA/cuDNN version: 10.0
- GPU model and memory: 12Gb
You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
2. TF 2.0: python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
Describe the current behavior
mIOU = tf.keras.metrics.MeanIoU(num_classes=20)
model.compile(optimizer='Adam',
loss='sparse_categorical_crossentropy',
metrics=["accuracy", mIOU])
Hi, sparse_categorical_crossentropy will calculate the probabilities of 20 classes, which have the shape (None, 64, 1024, 20). However, the label has the shape (None, 64, 1024). Thus, the mIOU got unequal shape inputs. It got errors
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 18
I believe this is the code which reproduces the issue:
Running this throws the following exception:
InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [100] != values[1].shape = [1000]