Skip to content

Commit

Permalink
[Fix] Fix loss parse in val_step
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyajie committed Sep 25, 2021
1 parent 186a1fc commit eb87ace
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mmseg/models/segmentors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,22 @@ def train_step(self, data_batch, optimizer, **kwargs):

return outputs

def val_step(self, data_batch, **kwargs):
def val_step(self, data_batch, optimizer=None, **kwargs):
"""The iteration step during validation.
This method shares the same signature as :func:`train_step`, but used
during val epochs. Note that the evaluation after training epochs is
not implemented with this method, but an evaluation hook.
"""
output = self(**data_batch, **kwargs)
return output
losses = self(**data_batch)
loss, log_vars = self._parse_losses(losses)

outputs = dict(
loss=loss,
log_vars=log_vars,
num_samples=len(data_batch['img_metas']))

return outputs

@staticmethod
def _parse_losses(losses):
Expand Down

0 comments on commit eb87ace

Please sign in to comment.