Refer to # https://github.com/tensorflow/tensorflow/issues/32875
The suggested fix was to :
class UpdatedMeanIoU(tf.keras.metrics.MeanIoU):
@tf.function
def __call__(self, y_true, y_pred, sample_weight=None):
y_pred = tf.argmax(y_pred, axis=-1) # this is the fix
return super().__call__(y_true, y_pred, sample_weight=sample_weight)
It worked for TF2.1, but broke again in TF2.2. Is there a way to pass y_pred = tf.argmax(y_pred, axis=-1) as y_pred to this metric other than subclassing ?