On Tensorflow official website, it gives explantions of the tf.initialize_all_variables()
and tf.global_variables_initializer()
functions as follow
tf.initialize_all_variables():
Returns an op that initializes all variables.
tf.global_variables_initializer():
Adds an op to initialize all variables in the model
It seems like both can be used to initialize all variables in graphs. Can we use these two functions exchangbly? If not, what would be the differences?
Unfortunately, you forgot to read an important line in the documentation of tf.initialize_all_variables
.
THIS FUNCTION IS DEPRECATED. It will be removed after 2017-03-02. Instructions for updating: Use
tf.global_variables_initializer
instead.
The changelog for 0.12 version tells you that both both functions do the same thing because:
tf.initialize_all_variables renamed to tf.global_variables_initializer
and as Martianwars mentioned the documentation for initialize_all_variables tells that:
THIS FUNCTION IS DEPRECATED. It will be removed after 2017-03-02. Instructions for updating: Use tf.global_variables_initializer instead.
If you will call it, you will get a warning as well. So you should always use tf.global_variables_initializer()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With