Skip to content

Commit

Permalink
perf(tuner): inference mode for torch evaluation (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadej Svetina committed Oct 5, 2021
1 parent 91587d8 commit 68fc783
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions finetuner/tuner/pytorch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def _eval(self, data, description: str = 'Evaluating'):

with ProgressBar(description, message_on_done=get_desc_str) as p:
for inputs, label in data:
outputs = self.wrapped_model(*inputs)
loss = self.wrapped_model.loss_fn(outputs, label)
metric = self.wrapped_model.metric_fn(outputs, label)
with torch.inference_mode():
outputs = self.wrapped_model(*inputs)
loss = self.wrapped_model.loss_fn(outputs, label)
metric = self.wrapped_model.metric_fn(outputs, label)

losses.append(loss.item())
metrics.append(metric.numpy())
Expand Down

0 comments on commit 68fc783

Please sign in to comment.