What is the difference between Keras model.evaluate() and model.predict()?

前端 未结 4 995
暗喜
暗喜 2020-12-29 04:48

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

4条回答
  •  离开以前
    2020-12-29 05:06

    The problem lies in the fact that every metric in Keras is evaluated in a following manner:

    1. For each batch a metric value is evaluated.
    2. A current value of loss (after k batches is equal to a mean value of your metric across computed k batches).
    3. The final result is obtained as a mean of all losses computed for all 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.

提交回复
热议问题