Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

tensorflow

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

like image 447
user77005 Avatar asked Feb 22 '17 23:02

user77005


People also ask

What is TF train feature?

The TFRecord format is a simple format for storing a sequence of binary records. Protocol buffers are a cross-platform, cross-language library for efficient serialization of structured data. Protocol messages are defined by . proto files, these are often the easiest way to understand a message type. The tf.

What is global step in Tensorflow?

global_step refers to the number of batches seen by the graph. Every time a batch is provided, the weights are updated in the direction that minimizes the loss. global_step just keeps track of the number of batches seen so far.


2 Answers

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.

like image 155
kafman Avatar answered Oct 22 '22 16:10

kafman


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.

like image 1
BugKiller Avatar answered Oct 22 '22 15:10

BugKiller