我在tensorflow中得到变量初始化错误,有人可以帮帮我吗?我在GPU上使用python版本(3.5.4)和TF版本(1.2.1)。在tensorflow和python库同步之间的差距似乎有些问题,如果我从代码中删除最后一行然后它的工作细
Sub test()
With ActiveSheet.Buttons.Add(53.25, 36.75, 190.5, 41.25)
.Name = "Blah"
.Text = "Blah"
.OnAction = "DoSomething"
With .ShapeRange
.IncrementLeft 222.75
.IncrementTop 147
.IncrementTop 147
End With
End With
End Sub
答案 0 :(得分:0)
您需要在初始化变量之前声明变量。以下代码应该有效:
in_size = 100
h1_size = 10
x = tf.placeholder(tf.float32,(None,in_size))
w = tf.Variable(tf.random_normal([in_size,h1_size]))
b = tf.Variable(tf.ones([h1_size]))
xw = tf.matmul(x,w)
z = tf.add(xw,b)
a = tf.nn.relu(z)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
yhat = sess.run(a,feed_dict={x:np.random.random([100000,in_size])})