Skip to content

Commit

Permalink
fix resume log
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuziyi616 committed Jun 10, 2021
1 parent 2b54eb7 commit 9715d78
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/analysis_tools/analyze_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ def plot_curve(log_dicts, args):
f'{args.json_logs[i]} does not contain metric {metric}')

if args.mode == 'eval':
xs = np.arange(args.interval, max(epochs) + 1, args.interval)
# if current training is resumed from previous checkpoint
# we lost information in early epochs
# `xs` should start according to `min(epochs)`
x0 = min(epochs) + args.interval - min(epochs) % args.interval
xs = np.arange(x0, max(epochs) + 1, args.interval)
ys = []
for epoch in epochs[args.interval - 1::args.interval]:
ys += log_dict[epoch][metric]

# if training is aborted before eval of the last epoch
# xs and ys will have different length and cause an error
# check if ys[-1] is empty here
# `xs` and `ys` will have different length and cause an error
# check if `ys[-1]` is empty here
if not log_dict[epoch][metric]:
xs = xs[:-1]

Expand Down

0 comments on commit 9715d78

Please sign in to comment.