Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Loss, Top1 and Top5 to iteration hook #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions robustness/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def train_model(args, model, loaders, *, checkpoint=None, dp_device_ids=None,
If given, this function is called every training iteration by
the training loop (useful for custom logging). The function is
given arguments `model, iteration #, loop_type [train/eval],
current_batch_ims, current_batch_labels`.
current_batch_ims, current_batch_labels, losses (AverageMeter), top1 accuracy (AverageMeter), top5 accuracy (AverageMeter)`.
epoch hook (function, optional)
Similar to iteration_hook but called every epoch instead, and
given arguments `model, log_info` where `log_info` is a
Expand Down Expand Up @@ -501,7 +501,7 @@ def _model_loop(args, loop_type, loader, model, opt, epoch, adv, writer):

# USER-DEFINED HOOK
if has_attr(args, 'iteration_hook'):
args.iteration_hook(model, i, loop_type, inp, target)
args.iteration_hook(model, i, loop_type, inp, target, losses, top1, top5)

iterator.set_description(desc)
iterator.refresh()
Expand Down