'Keras ModelCheckpoint val_loss decreases but says it doesn't

I use a ModelCheckPoint in Keras to save only the best models. Although, I see the val_loss decreasing the ModelCheckPoint says; No.

Any ideas?

checkpoint = ModelCheckpoint(filepath, monitor='val_loss', verbose=1,
                             save_best_only=True,
                             mode='max')

This is the last bit of output before finalizing the epoch. As far as I see the val_loss is 4.6578 which is lower than 10.44941.

3648/3768 [============================>.] - ETA: 0s - loss: 3.7331 - acc: 0.1812
3712/3768 [============================>.] - ETA: 0s - loss: 3.7264 - acc: 0.1810
3768/3768 [==============================] - 16s 4ms/step - loss: 3.7243 - acc: 0.1802 - val_loss: 4.6578 - val_acc: 0.1643

Epoch 00056: val_loss did not improve from 10.44941


Solution 1:[1]

Change mode='max' to mode='min' in ModelCheckpoint since you are minimizing loss and not maximizing it. See documentation in https://keras.io/callbacks/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tRosenflanz