orbit.utils.create_global_step
Stay organized with collections
Save and categorize content based on your preferences.
Creates a tf.Variable
suitable for use as a global step counter.
orbit.utils.create_global_step() -> tf.Variable
Creating and managing a global step variable may be necessary for
AbstractTrainer
subclasses that perform multiple parameter updates per
Controller
"step", or use different optimizers on different steps.
In these cases, an optimizer.iterations
property generally can't be used
directly, since it would correspond to parameter updates instead of iterations
in the Controller
's training loop. Such use cases should simply call
step.assign_add(1)
at the end of each step.
Returns |
A non-trainable scalar tf.Variable of dtype tf.int64 , with only the
first replica's value retained when synchronizing across replicas in
a distributed setting.
|
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 2025-04-18 UTC.
[null,null,["Last updated 2025-04-18 UTC."],[],[],null,["# orbit.utils.create_global_step\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.19.1/orbit/utils/common.py#L22-L44) |\n\nCreates a [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable) suitable for use as a global step counter. \n\n orbit.utils.create_global_step() -\u003e tf.Variable\n\nCreating and managing a global step variable may be necessary for\n`AbstractTrainer` subclasses that perform multiple parameter updates per\n`Controller` \"step\", or use different optimizers on different steps.\n\nIn these cases, an `optimizer.iterations` property generally can't be used\ndirectly, since it would correspond to parameter updates instead of iterations\nin the `Controller`'s training loop. Such use cases should simply call\n`step.assign_add(1)` at the end of each step.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A non-trainable scalar [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable) of dtype [`tf.int64`](https://www.tensorflow.org/api_docs/python/tf#int64), with only the first replica's value retained when synchronizing across replicas in a distributed setting. ||\n\n\u003cbr /\u003e"]]