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

Exponential moving averages of model parameters #321

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AntonioMirarchi
Copy link
Contributor

Enhance model training by enabling Exponential Moving Average (EMA) on the model parameters. To activate this feature, simply specify the ema_prmtrs_decay arg in the configuration file. If not set, its default value is None, indicating that EMA is not going to be applied.

@@ -17,3 +17,5 @@ dependencies:
- pytest
- psutil
- gxx<12
- pip:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this is a dangerous idea. Note that this project you link to is a short and single MIT-licensed class: https://github.com/fadel/pytorch_ema/blob/master/torch_ema/ema.py

I would consider just including it in the repo with the appropriate copyright notice.

@@ -73,6 +74,11 @@ def __init__(self, hparams, prior_model=None, mean=None, std=None):
else:
self.model = create_model(self.hparams, prior_model, mean, std)

self.ema_prmtrs = None
if self.hparams.ema_prmtrs_decay is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail because of this. You have to first make sure the element exists, see how its done with the charge above:

        if "charge" not in hparams:

Alternatively you can deal with hparams as a dict before the call to save_hyperparameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants