The difference between the function tf.initialize_all_variables() and tf.global_variables_initializer()

Both are exactly the same
 

  • The official tensorflow document states that tf.initialize_all_variables() will be abandoned, so it is recommended to use tf.global_variables_initializer()
     
  • effect:
    • Return an op, which is used to initialize all global variables
  • Specific explanation of tf.global_variables_initializer():
    • After running tf.global_variables_initializer() in a session, variables will hold the initialized values ​​assigned to them (tf.Variable(tf.zeros(...)), tf.Variable(tf. random_normal(...)))
       
  • Note :
    • The variable in the neural network is initialized. It is required to be added only after the variable is defined. If there is no variable defined, there is no need to add this statement to initialize

Guess you like

Origin blog.csdn.net/qq_42546127/article/details/114667568