How do I solve Kera's MeanIoU Confusion matrix error?

338 Views Asked by At

I am using Tensorflow 2.8. When I try evaluating my pre-trained(pix2pix) image segmentation model using MeanIoU, I get the errors below:

Node: 'confusion_matrix/assert_non_negative_1/assert_less_equal/Assert/AssertGuard/Assert'
2 root error(s) found.
  (0) INVALID_ARGUMENT:  assertion failed: [`predictions` contains negative values.  ] [Condition x >= 0 did not hold element-wise:] [x (confusion_matrix/Cast:0) = ] [0 0 0...]
     [[{{node confusion_matrix/assert_non_negative_1/assert_less_equal/Assert/AssertGuard/Assert}}]]
     [[confusion_matrix/assert_less_1/Assert/AssertGuard/pivot_f/_31/_65]]
  (1) INVALID_ARGUMENT:  assertion failed: [`predictions` contains negative values.  ] [Condition x >= 0 did not hold element-wise:] [x (confusion_matrix/Cast:0) = ] [0 0 0...]
     [[{{node confusion_matrix/assert_non_negative_1/assert_less_equal/Assert/AssertGuard/Assert}}]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_50298]

Here is my compilation code:

myTransformer.compile(optimizer='adam',
              loss = DiceLoss(),
              metrics=[tf.keras.metrics.MeanIoU(num_classes=100)])

I have tried changing num_classes to many values eg:10,100,1000,10000, and it still doesn't work. Do you have a fix for this?

0

There are 0 best solutions below