I used Keras biomedical image segmentation to segment brain neurons. I used model.evaluate()
it gave me Dice coefficient: 0.916. However, when I used mode
The problem lies in the fact that every metric in Keras
is evaluated in a following manner:
batch
a metric value is evaluated.k
batches is equal to a mean value of your metric across computed k
batches).Most of the most popular metrics (like mse
, categorical_crossentropy
, mae
) etc. - as a mean of loss value of each example - have a property that such evaluation ends up with a proper result. But in case of Dice Coefficient - a mean of its value across all of the batches is not equal to actual value computed on a whole dataset and as model.evaluate()
uses such way of computations - this is the direct cause of your problem.