Skip to content

Commit

Permalink
[Fix] Fix val_loss when the output is not list
Browse files Browse the repository at this point in the history
  • Loading branch information
fanqiNO1 committed Nov 9, 2024
1 parent 9124ebf commit aefa284
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mmengine/runner/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ def run_iter(self, idx, data_batch: Sequence[dict]):
with autocast(enabled=self.fp16):
outputs = self.runner.model.val_step(data_batch)

outputs, self.val_loss = _update_losses(outputs, self.val_loss)
if isinstance(outputs, list):
outputs, self.val_loss = _update_losses(outputs, self.val_loss)

self.evaluator.process(data_samples=outputs, data_batch=data_batch)
self.runner.call_hook(
Expand Down Expand Up @@ -486,7 +487,8 @@ def run_iter(self, idx, data_batch: Sequence[dict]) -> None:
with autocast(enabled=self.fp16):
outputs = self.runner.model.test_step(data_batch)

outputs, self.test_loss = _update_losses(outputs, self.test_loss)
if isinstance(outputs, list):
outputs, self.test_loss = _update_losses(outputs, self.test_loss)

self.evaluator.process(data_samples=outputs, data_batch=data_batch)
self.runner.call_hook(
Expand Down

0 comments on commit aefa284

Please sign in to comment.