Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Remove Epoch training metric log
Browse files Browse the repository at this point in the history
  • Loading branch information
vandanavk committed Aug 25, 2018
1 parent 15e43c0 commit 0339f79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
10 changes: 3 additions & 7 deletions example/kaggle-ndsb1/training_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,22 @@
import re
import argparse

parser = argparse.ArgumentParser(description='Parses log file and generates train/val curves')
parser.add_argument('--log-file', type=str,default="log_tr_va",
parser = argparse.ArgumentParser(description='Parses log file and generates val curves')
parser.add_argument('--log-file', type=str,default="log_va",
help='the path of log file')
args = parser.parse_args()


TR_RE = re.compile('.*?]\sTrain-accuracy=([\d\.]+)')
VA_RE = re.compile('.*?]\sValidation-accuracy=([\d\.]+)')

log = open(args.log_file).read()

log_tr = [float(x) for x in TR_RE.findall(log)]
log_va = [float(x) for x in VA_RE.findall(log)]
idx = np.arange(len(log_tr))
idx = np.arange(len(log_va))

plt.figure(figsize=(8, 6))
plt.xlabel("Epoch")
plt.ylabel("Accuracy")
plt.plot(idx, log_tr, 'o', linestyle='-', color="r",
label="Train accuracy")

plt.plot(idx, log_va, 'o', linestyle='-', color="b",
label="Validation accuracy")
Expand Down
6 changes: 0 additions & 6 deletions python/mxnet/module/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,6 @@ def fit(self, train_data, eval_data=None, eval_metric='acc',
if monitor is not None:
monitor.toc_print()

if end_of_batch:
eval_name_vals = eval_metric.get_name_value()

if batch_end_callback is not None:
batch_end_params = BatchEndParam(epoch=epoch, nbatch=nbatch,
eval_metric=eval_metric,
Expand All @@ -553,9 +550,6 @@ def fit(self, train_data, eval_data=None, eval_metric='acc',
callback(batch_end_params)
nbatch += 1

# one epoch of training is finished
for name, val in eval_name_vals:
self.logger.info('Epoch[%d] Train-%s=%f', epoch, name, val)
toc = time.time()
self.logger.info('Epoch[%d] Time cost=%.3f', epoch, (toc-tic))

Expand Down
7 changes: 3 additions & 4 deletions tools/parse_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
with open(args.logfile[0]) as f:
lines = f.readlines()

res = [re.compile('.*Epoch\[(\d+)\] Train-'+s+'.*=([.\d]+)') for s in args.metric_names]\
+ [re.compile('.*Epoch\[(\d+)\] Validation-'+s+'.*=([.\d]+)') for s in args.metric_names]\
res = [re.compile('.*Epoch\[(\d+)\] Validation-'+s+'.*=([.\d]+)') for s in args.metric_names]\
+ [re.compile('.*Epoch\[(\d+)\] Time.*=([.\d]+)')]

data = {}
Expand All @@ -63,11 +62,11 @@
data[epoch][i*2+1] += 1

if args.format == 'markdown':
print("| epoch | " + " | ".join(['train-'+s for s in args.metric_names]) + " | " + " | ".join(['val-'+s for s in args.metric_names]) + " | time |")
print("| epoch | " + " | ".join(['val-'+s for s in args.metric_names]) + " | time |")
print("| --- "*(len(res)+1) + "|")
for k, v in data.items():
print("| %2d | " % (k+1)\
+ " | ".join(["%f" % (v[2*j]/v[2*j+1]) for j in range(2*len(args.metric_names))])\
+ " | ".join(["%f" % (v[2*j]/v[2*j+1]) for j in range(len(args.metric_names))])\
+ " | %.1f |" % (v[-2]/v[-1]))
elif args.format == 'none':
print("\t".join(['epoch'] + ['train-' + s for s in args.metric_names] + ['val-' + s for s in args.metric_names] + ['time']))
Expand Down

0 comments on commit 0339f79

Please sign in to comment.