What is the difference between tf.initialize_all_variables() and tf.initialize_local_variables()?

前端 未结 3 882
梦谈多话
梦谈多话 2020-12-31 19:52

I am reviewing the code in this example: fully_connected_reader.py

I am confused with Line 147 and 148:

init_op = tf.group(tf.initialize_all_variable         


        
3条回答
  •  被撕碎了的回忆
    2020-12-31 20:32

    tf.initialize_all_variables() is a shortcut to tf.initialize_variables(tf.all_variables()), tf.initialize_local_variables() is a shortcut to tf.initialize_variables(tf.local_variables()), which initializes variables in GraphKeys.VARIABLES and GraphKeys.LOCAL_VARIABLE collections, respectively.

    Variables in GraphKeys.LOCAL_VARIABLES collection are variables that are added to the graph, but not saved or restored (source).

    tf.Variable() by default adds a new variable to GraphKeys.VARIABLE collection, which can be controlled by collections= argument.

提交回复
热议问题