說明
最近在使用allennlp
框架訓練一個簡單的分類模型的時候,設置test_data_path
的時候突然想到,雖然設置了test_data
,但是在訓練結果輸出的時候並沒有test acc
的影子,於是看了一下源碼:
test_data_path: `str`, optional (default=None)
If given, we will use this as test data. This makes it available for vocab creation by
default, but nothing else.
evaluate_on_test: `bool`, optional (default=False)
If given, we will evaluate the final model on this data at the end of training. Note
that we do not recommend using this for actual test data in every-day experimentation;
you should only very rarely evaluate your model on actual test data.
意思是說:該框架在整個模型訓練最後一次纔會在test_data
上進行驗證,結果如下:
- INFO - allennlp.common.util - Metrics: {
"best_epoch": 2,
"training_start_epoch": 0,
"training_epochs": 3,
"epoch": 3,
"training_accuracy": 0.8842257597684515,
"validation_accuracy": 0.8823529411764706,
"best_validation_accuracy": 0.8941176470588236,
"test_accuracy": 0.8620689655172413,
"test_0_precision": 0.9078947305679321,
"test_0_recall": 0.9324324131011963,
"test_0_fscore": 0.9199999570846558,
"test_1_precision": 0.5454545617103577,
"test_1_recall": 0.4615384638309479,
"test_1_fscore": 0.5,
"test_loss": 0.318086966044373
}