警告:不推荐使用tensorflow - initialize_all_variables(来自tensorflow.python.ops.variables)

时间:2017-01-31 16:07:37

标签: python tensorflow

初始化张量流

init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)

低于警告

WARNING:tensorflow:From D:/Projects/Python/DLPractice/boston_housing.py:75 in <module>.: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.

如何删除警告并使用更新的代码?

1 个答案:

答案 0 :(得分:11)

解决方案是使用更新后的方法global_variables_initializer()代替initialize_all_variables

init = tf.global_variables_initializer()