EMA
discrete_diffusion.models.ema
ExponentialMovingAverage
Maintains (exponential) moving average of a set of parameters.
Source code in src/discrete_diffusion/models/ema.py
__init__(parameters, decay, use_num_updates=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable of |
required | |
decay
|
The exponential decay. |
required | |
use_num_updates
|
Whether to use number of updates when computing averages. |
True
|
Source code in src/discrete_diffusion/models/ema.py
copy_to(parameters)
Copy current parameters into given collection of parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable of |
required |
Source code in src/discrete_diffusion/models/ema.py
restore(parameters)
Restore the parameters stored with the store method.
Useful to validate the model with EMA parameters without affecting the
original optimization process. Store the parameters before the
copy_to method. After validation (or model saving), use this to
restore the former parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable of |
required |
Source code in src/discrete_diffusion/models/ema.py
store(parameters)
Save the current parameters for restoring later.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable of |
required |
Source code in src/discrete_diffusion/models/ema.py
update(parameters)
Update currently maintained parameters.
Call this every time the parameters are updated, such as the result of
the optimizer.step() call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable of |
required |