How to statistics epoch training accuracy?
Using such pieces of code will log out the training accuracy every specified number of batch.
eval_metrics = ['accuracy']
batch_end_callback.append(mx.callback.Speedometer(args.batch_size, 50))
model.fit(
X = train,
eval_data = val,
eval_metric = eval_metrics,
kvstore = kv,
batch_end_callback = batch_end_callback,
epoch_end_callback = checkpoint)
logging info shows as below:
2016-08-12 20:15:43,819 Node[0] Epoch[5] Batch [50] Speed: 444.47 samples/sec Train-accuracy=0.844219
2016-08-12 20:15:43,819 Node[0] Epoch[5] Batch [50] Speed: 444.47 samples/sec Train-top_k_accuracy_5=0.994219
2016-08-12 20:15:43,820 Node[0] Epoch[5] Batch [50] Speed: 444.47 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:15:43,820 Node[0] Epoch[5] Batch [50] Speed: 444.47 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:15:58,518 Node[0] Epoch[5] Batch [100] Speed: 435.42 samples/sec Train-accuracy=0.846094
2016-08-12 20:15:58,519 Node[0] Epoch[5] Batch [100] Speed: 435.42 samples/sec Train-top_k_accuracy_5=0.995625
2016-08-12 20:15:58,519 Node[0] Epoch[5] Batch [100] Speed: 435.42 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:15:58,519 Node[0] Epoch[5] Batch [100] Speed: 435.42 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:16:13,001 Node[0] Epoch[5] Batch [150] Speed: 441.95 samples/sec Train-accuracy=0.860938
2016-08-12 20:16:13,001 Node[0] Epoch[5] Batch [150] Speed: 441.95 samples/sec Train-top_k_accuracy_5=0.995000
2016-08-12 20:16:13,001 Node[0] Epoch[5] Batch [150] Speed: 441.95 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:16:13,001 Node[0] Epoch[5] Batch [150] Speed: 441.95 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:16:26,907 Node[0] Epoch[5] Batch [200] Speed: 460.24 samples/sec Train-accuracy=0.852344
2016-08-12 20:16:26,908 Node[0] Epoch[5] Batch [200] Speed: 460.24 samples/sec Train-top_k_accuracy_5=0.993750
2016-08-12 20:16:26,908 Node[0] Epoch[5] Batch [200] Speed: 460.24 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:16:26,908 Node[0] Epoch[5] Batch [200] Speed: 460.24 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:16:41,463 Node[0] Epoch[5] Batch [250] Speed: 439.71 samples/sec Train-accuracy=0.853125
2016-08-12 20:16:41,463 Node[0] Epoch[5] Batch [250] Speed: 439.71 samples/sec Train-top_k_accuracy_5=0.994219
2016-08-12 20:16:41,464 Node[0] Epoch[5] Batch [250] Speed: 439.71 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:16:41,464 Node[0] Epoch[5] Batch [250] Speed: 439.71 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:16:56,109 Node[0] Epoch[5] Batch [300] Speed: 437.00 samples/sec Train-accuracy=0.859219
2016-08-12 20:16:56,110 Node[0] Epoch[5] Batch [300] Speed: 437.00 samples/sec Train-top_k_accuracy_5=0.994375
2016-08-12 20:16:56,110 Node[0] Epoch[5] Batch [300] Speed: 437.00 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:16:56,110 Node[0] Epoch[5] Batch [300] Speed: 437.00 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:17:10,784 Node[0] Epoch[5] Batch [350] Speed: 436.15 samples/sec Train-accuracy=0.855313
2016-08-12 20:17:10,784 Node[0] Epoch[5] Batch [350] Speed: 436.15 samples/sec Train-top_k_accuracy_5=0.995625
2016-08-12 20:17:10,785 Node[0] Epoch[5] Batch [350] Speed: 436.15 samples/sec Train-top_k_accuracy_10=1.000000
2016-08-12 20:17:10,785 Node[0] Epoch[5] Batch [350] Speed: 436.15 samples/sec Train-top_k_accuracy_20=1.000000
2016-08-12 20:17:22,049 Node[0] Epoch[5] Resetting Data Iterator
Can I statistic or estimate training accuracy per epoch by some means? thanks!
Write your own epoch_end_callback function
If you provide validation data, by default it also logs validation accuracy per epoch. https://github.com/dmlc/mxnet/blob/master/python/mxnet/model.py#L306
Got it, I can write the epoch callback function to eval the acc, @VoVAllen, @eric-haibin-lin ,thanks for help!
@pinglforever hi, Can you tell how do you did it ? I am trying to print the loss in each 20 epochs.
You can edit this line to check every 20 epoch @salemmohammed
https://github.com/dmlc/mxnet/blob/master/python/mxnet/module/base_module.py#L488