Course 3 week 3 UNet colab class_wise_metrics

I am wondering if the class wise metrics are calculated correctly.
I think the summation should go after the division is done per image.
shouldn’t we first calculate in matrix form (for each image separately)
iou = (intersection + smoothening_factor) / (combined_area - intersection + smoothening_factor)
then sum "iou"s together?

I think the cummulative effect is the same.

There is division involved. Can’t be the same

The summation is a vectorized operation for different predicted classes in y_pred. The classification is at pixel level for one image only, not across different images.

y_true_images, y_true_segments = get_test_image_and_annotation_arrays()

feed the test set to th emodel to get the predicted masks

results = model.predict(test_dataset, steps=info.splits[‘test’].num_examples//BATCH_SIZE)

results = np.argmax(results, axis=3)

results = results[…, tf.newaxis]
cls_wise_iou, cls_wise_dice_score = class_wise_metrics(y_true_segments, results)

It is calculated over the results which is the results of prediction over the test set which has around 3000 images.