#coding:utf-8
import tensorflow as tf
tf.compat.v1.disable_eager_execution() # 保证sess.run能正常运行
x=tf.constant([[1.0,3.0],[4.0,6.0],[8.0,6.0],[9.0,3.0]],name='x')
#第一层权重
w0=tf.compat.v1.Variable(tf.random.normal([2,4],stddev=0.35,mean=0,seed=1),name='wo')
#第二层权重
w1=tf.compat.v1.Variable(tf.random.normal([4,1],stddev=0.35,mean=0,seed=1),name='w1')
#整理前向网络结构
l1=tf.matmul(x,w0)
l2=tf.matmul(l1,w1)
init_op=tf.compat.v1.global_variables_initializer()
#执行计算图
with tf.compat.v1.Session() as sess:
print(sess.run(w0))
我已经有初始化了,但还是报错:This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/wo)