W1 assignment 1

I got a problem with the function to output the weighted loss. Can anyone help me point out my mistake?
Although it outputs the same values in the example, the values are not correct.
for i in range(len(pos_weights)):
# for each class, add average weighted loss for that class
pos_weight = pos_weights[i]
neg_weight = neg_weights[i]
pos_loss = pos_weight * y_true * K.log(y_pred + epsilon)
neg_loss = neg_weight * (1-y_true) * K.log(1-y_pred + epsilon)
loss -= K.mean(pos_loss + neg_loss)
return loss

The problem is in y_true and y_pred. You know that these two variables are 2D array. We don’t need all of the rows and columns.


Got it, thank you for your help