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

Fix bug in periodic eval - number of worker not passed to the eval method #1012

Merged
merged 3 commits into from
May 5, 2022
Merged
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
18 changes: 10 additions & 8 deletions avalanche/training/templates/base_sgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def before_training(self, strategy, **kwargs):
training.
"""
if self.do_initial:
self._peval(strategy)
self._peval(strategy, **kwargs)

def before_training_exp(self, strategy, **kwargs):
# We evaluate at the start of each experience because train_epochs
Expand All @@ -381,24 +381,26 @@ def before_training_exp(self, strategy, **kwargs):
def after_training_exp(self, strategy, **kwargs):
"""Final eval after a learning experience."""
if self.do_final:
self._peval(strategy)
self._peval(strategy, **kwargs)

def _peval(self, strategy):
def _peval(self, strategy, **kwargs):
for el in strategy._eval_streams:
strategy.eval(el)
strategy.eval(el, **kwargs)

def _maybe_peval(self, strategy, counter):
def _maybe_peval(self, strategy, counter, **kwargs):
if self.eval_every > 0 and counter % self.eval_every == 0:
self._peval(strategy)
self._peval(strategy, **kwargs)

def after_training_epoch(self, strategy: "BaseSGDTemplate", **kwargs):
"""Periodic eval controlled by `self.eval_every` and
`self.peval_mode`."""
if self.peval_mode == "epoch":
self._maybe_peval(strategy, strategy.clock.train_exp_epochs)
self._maybe_peval(strategy, strategy.clock.train_exp_epochs,
**kwargs)

def after_training_iteration(self, strategy: "BaseSGDTemplate", **kwargs):
"""Periodic eval controlled by `self.eval_every` and
`self.peval_mode`."""
if self.peval_mode == "iteration":
self._maybe_peval(strategy, strategy.clock.train_exp_iterations)
self._maybe_peval(strategy, strategy.clock.train_exp_iterations,
**kwargs)