为什么初始化后所有变量均为零。 (使用tf.random_normal())

时间:2018-07-27 11:01:36

标签: python tensorflow random initialization

我的朋友具有相同代码的随机值, 我认为这是张量流的问题。

这是我的代码:

import tensorflow as tf

w1 = tf.random_normal([2,3], stddev=1, seed=1)
w2 = tf.random_normal([3,1], stddev=1, seed=1)

sess = tf.Session()

init=tf.global_variables_initializer()
sess.run(init)

print(sess.run(w1))
print(sess.run(w2))

sess.close()

输出:

[[ 0.  0.  0.]
 [ 0.  0.  0.]]
[[ 0.]
 [ 0.]
 [ 0.]]

我使用anaconda3,python3.6.5,tensorflow是gpu ver。 有人可以告诉我如何解决? 谢谢你

0 个答案:

没有答案