tfm.core.actions.EMACheckpointing
Stay organized with collections
Save and categorize content based on your preferences.
Eval action to save checkpoint with average weights when EMA is used.
tfm.core.actions.EMACheckpointing(
export_dir: str,
optimizer: tf.keras.optimizers.Optimizer,
checkpoint: tf.train.Checkpoint,
max_to_keep: int = 1
)
This action swaps the weights of the model with the average weights, then it
saves the checkpoint under export_dir/ema_checkpoints. Checkpointing is
expensive for large models, so doing this action in eval is more efficient
than training.
Args |
export_dir
|
str for the export directory of the EMA average weights.
|
optimizer
|
tf.keras.optimizers.Optimizer optimizer instance used for
training. This will be used to swap the model weights with the average
weigths.
|
checkpoint
|
tf.train.Checkpoint instance.
|
max_to_keep
|
int for max checkpoints to keep in ema_checkpoints subdir.
|
Methods
__call__
View source
__call__(
output: orbit.runner.Output
)
Swaps model weights, and saves the checkpoint.
Args |
output
|
The train or eval output.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-02-02 UTC.
[null,null,["Last updated 2024-02-02 UTC."],[],[],null,["# tfm.core.actions.EMACheckpointing\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.15.0/official/core/actions.py#L76-L123) |\n\nEval action to save checkpoint with average weights when EMA is used. \n\n tfm.core.actions.EMACheckpointing(\n export_dir: str,\n optimizer: tf.keras.optimizers.Optimizer,\n checkpoint: tf.train.Checkpoint,\n max_to_keep: int = 1\n )\n\nThis action swaps the weights of the model with the average weights, then it\nsaves the checkpoint under export_dir/ema_checkpoints. Checkpointing is\nexpensive for large models, so doing this action in eval is more efficient\nthan training.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `export_dir` | `str` for the export directory of the EMA average weights. |\n| `optimizer` | [`tf.keras.optimizers.Optimizer`](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/Optimizer) optimizer instance used for training. This will be used to swap the model weights with the average weigths. |\n| `checkpoint` | [`tf.train.Checkpoint`](https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint) instance. |\n| `max_to_keep` | `int` for max checkpoints to keep in ema_checkpoints subdir. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/models/blob/v2.15.0/official/core/actions.py#L115-L123) \n\n __call__(\n output: orbit.runner.Output\n )\n\nSwaps model weights, and saves the checkpoint.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|---------------------------|\n| `output` | The train or eval output. |\n\n\u003cbr /\u003e"]]