Why do we name variables in Tensorflow?

前端 未结 4 803
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 01:53

In some of the places, I saw the syntax, where variables are initialized with names, sometimes without names. For example:

# With name
var = tf.Variable(0, n         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 01:56

    You can imagine Python namespace and TensorFlow namespace as two parallel universes. Names in TensorFlow space are actually the "real" attributes belonging to any TensorFlow variables, while names in Python space are just temporary pointers pointing to TensorFlow variables during this run of your script. That is the reason why when saving and restoring variables, only TensorFlow names are used, because the Python namespace no longer exists after script being terminated, but Tensorflow namespace is still there in your saved files.

提交回复
热议问题