orbit.utils.create_global_step

Creates a tf.Variable suitable for use as a global step counter.

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.

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.