Issue with the model

Hello @Dennis_Sinitsky

  1. In UNQ_C2 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
    def standardize(image):
    under the if statement, you have added an else statement which is not required, kindly remove it
    divide by the standard deviation (only if it is different from zero)
    else:
    centered_scaled = centered

  2. UNQ_C3 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
    def single_class_dice_coefficient

FOR DICE NUMERATOR As I said in the previous comments, you have used incorrect operator to calculate dice_numerator and dice_denominator
while calculating instead of using * operator between y_pred and y_true values you have used tf.multiply.
Also while calculating numerator, remember it is
({2 \times \sum_{i, j} f(x){ij} \times y{ij} )+ \epsilon}
notice there need to be one more tuple for A * B and epsilon without tuple

FOR DICE DENOMINATOR: you have applied incorrect code which would be used in soft dice loss for dice_denominator. Also same mistake as far as for the operator * needs to be used, avoid using tf.multiply.

  1. UNQ_C4 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
    def dice_coefficient

Removed the below code
Convert to NumPy arrays if they are TensorFlow tensors
if K.is_tensor(y_true):
y_true = K.eval(y_true)
if K.is_tensor(y_pred):
y_pred = K.eval(y_pred)
num_classes = y_true.shape[0]
print(“Number of classes:”, num_classes)

for dice cofficient, there is an instructions mentioned as
Implement the mean dice coefficient below. This should not be very different from your singe-class implementation.
So your codes for dice numerator and dice denominator will be same as in single class cofficient.
The only difference in this code cell would be for the dice cofficient where you will calculate mean(dice_numerator/dice_denomination) (but remember Please use the K.mean function to take the average of the three classes.)
Also don’t forget that extra tuple required before the epsilon for dice_numerator

  1. UNQ_C5 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
    def soft_dice_loss
    your codes are written correctly but dice_numerator requires an extra tuple for 2 * K.mean of y_pred and y_true with axis
    also remember dice_loss is 1 - K.mean of dice_numerator/dice_denominator and not 1.0-K.mean. change 1.0 to 1

  2. No codes written for
    UNQ_C6 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
    def compute_class_sens_spec

here you calculate tp, tn, fp, and fn using numpy sum using the respective class pred and class labels for their respective classes.
Then using this tp, tn, fp and fn you calculate sensitivity and specificity(EXTRA HINT: MAKE SURE YOU TUPLE THE DENOMINATORS FOR BOTH SENSITIVITY AND SPECIFICITY)

Let me know if the issue is resolved, feel free to ask any doubt.

Regards
DP