user77005
user77005

Reputation: 1849

What does tf.train.get_global_step() do in TensorFlow?

What is the use of the function tf.train.get_global_step() in TensorFlow? In machine learning concepts what is it equivalent to?

Upvotes: 9

Views: 7109

Answers (3)

BugKiller
BugKiller

Reputation: 1488

tf.train.get_global_step() return global step(variable, tensor from variable node or None) through get_collection(tf.GraphKeys.GLOBAL_STEP) or get_tensor_by_name('global_step:0')

global step is widely used in learn rate decay(like tf.train.exponential_decay, see Decaying the learning rate for more information).

You can pass global step to optimzer apply_gradients or minimize method to increment by one.

Upvotes: 1

kafman
kafman

Reputation: 2860

You could use it to restart training exactly where you left off when the training procedure has been stopped for some reason. Of course you can always restart training without knowing the global_step (if you save checkpoints regularly in your code, that is), but unless you somehow keep track of how many iterations you already performed, you will not know how many iterations are left after the restart. Sometimes you really want your model to be trained exactly n iterations and not n plus unknown amount before crash. So in my opinion, this is more of a practicality than a theoretical machine learning concept.

Upvotes: 12

Tianjin Gu
Tianjin Gu

Reputation: 784

while you defined the global step operator, you can get value of it by sess.run(global_step_op)

Upvotes: 0

Related Questions