0

我有以下早期停止,但它停止得太快了。我想知道它是否在val_ndcg_metric减少时考虑损失改善(不应该是这种情况,因为 ndcg 越大越好)。

early_stopping = EarlyStopping(monitor='val_ndcg_metric', 
                               patience = 5,
                               restore_best_weights = True, 
                               min_delta = 0.001,
                               mode='auto',
                               verbose=2,
                               baseline=None)
    
model.fit(cached_train, 
          epochs=epochs, 
          verbose=True,
          validation_data=cached_validation,
          callbacks=[early_stopping])

结果如下:

Epoch 1/100
287/287 [==============================] - 68s 220ms/step - ndcg_metric: 0.7687 - root_mean_squared_error: 0.7584 - loss: 19.7870 - regularization_loss: 0.0000e+00 - total_loss: 19.7870 - val_ndcg_metric: 0.8302 - val_root_mean_squared_error: 1.1678 - val_loss: 19.6306 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.6306
Epoch 2/100
287/287 [==============================] - 62s 215ms/step - ndcg_metric: 0.8403 - root_mean_squared_error: 1.6596 - loss: 19.6016 - regularization_loss: 0.0000e+00 - total_loss: 19.6016 - val_ndcg_metric: 0.8659 - val_root_mean_squared_error: 2.0399 - val_loss: 19.4413 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.4413
Epoch 3/100
287/287 [==============================] - 62s 216ms/step - ndcg_metric: 0.8679 - root_mean_squared_error: 2.1857 - loss: 19.4620 - regularization_loss: 0.0000e+00 - total_loss: 19.4620 - val_ndcg_metric: 0.8874 - val_root_mean_squared_error: 2.2495 - val_loss: 19.2740 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.2740
Epoch 4/100
287/287 [==============================] - 62s 215ms/step - ndcg_metric: 0.8861 - root_mean_squared_error: 2.2456 - loss: 19.3463 - regularization_loss: 0.0000e+00 - total_loss: 19.3463 - val_ndcg_metric: 0.8982 - val_root_mean_squared_error: 2.2170 - val_loss: 19.1935 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.1935
Epoch 5/100
287/287 [==============================] - 62s 215ms/step - ndcg_metric: 0.8945 - root_mean_squared_error: 2.2081 - loss: 19.2647 - regularization_loss: 0.0000e+00 - total_loss: 19.2647 - val_ndcg_metric: 0.9027 - val_root_mean_squared_error: 2.1765 - val_loss: 19.1420 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.1420
Epoch 6/100
287/287 [==============================] - 62s 216ms/step - ndcg_metric: 0.8987 - root_mean_squared_error: 2.1843 - loss: 19.2139 - regularization_loss: 0.0000e+00 - total_loss: 19.2139 - val_ndcg_metric: 0.9060 - val_root_mean_squared_error: 2.1654 - val_loss: 19.0738 - val_regularization_loss: 0.0000e+00 - val_total_loss: 19.0738
Restoring model weights from the end of the best epoch.
Epoch 00006: early stopping
277/277 [==============================] - 24s 88ms/step - ndcg_metric: 0.8323 - root_mean_squared_error: 1.1680 - loss: 19.6501 - regularization_loss: 0.0000e+00 - total_loss: 19.6501

我将不胜感激对此的任何想法。

4

1 回答 1

1

我不知道 val_ndcg_metric 是什么,但显然你希望它随着模型训练而增加。在回调中设置 mode='auto'。尝试设置 mode='max'。如果 val_ndcg_metric 的值停止增加一段时间,这将停止训练。

于 2021-10-27T19:47:17.047 回答