Skip to content

Commit

Permalink
use numel instead of dim in engine logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cdancette authored and Cadene committed Jul 17, 2020
1 parent 728c283 commit 05b7ce5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bootstrap/engines/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def train_epoch(self, model, dataset, optimizer, epoch, mode='train'):

for key, value in out.items():
if torch.is_tensor(value):
if value.dim() <= 1:
value = value.item() # get number from a torch scalar
if value.numel() <= 1:
value = value.item() # get number from a torch scalar
else:
continue
if isinstance(value, (list, dict, tuple)):
Expand Down

0 comments on commit 05b7ce5

Please sign in to comment.