python_for_microscopists
python_for_microscopists copied to clipboard
Issue with Y_pred
Hello, I am trying figure out what values that y_pred tensor that passed as argument to jaccard_coef function consists. I usually think it should consists of probabilities of pixels. If yes, how should we multiply the tensor with floats i.e., probabilities of pixels with the Y_true which consists of unsigned integers i.e., 0's or 1's. Please clarify my doubt regarding this. And when I fit my data with the model with defined jaccard_coef and loss, I am getting a error of Input 'y' of 'Mul' Op has type float32 that does not match type uint8 of argument 'x'. Please clarify, Thank you.
def jacard_coef(y_true, y_pred): y_true_f = tf.cast(K.flatten(y_true), tf.float32) y_pred_f = tf.cast(K.flatten(y_pred),tf.float32) intersection = K.sum(y_true_f * y_pred_f) return (intersection + 1.0) / (K.sum(y_true_f) + K.sum(y_pred_f) - intersection + 1.0)