Unit testing Tensorflow完全连接在单元测试用例中不工作?
我一定错过了一些基本的东西。这是我的测试用例-Unit testing Tensorflow完全连接在单元测试用例中不工作?,unit-testing,tensorflow,Unit Testing,Tensorflow,我一定错过了一些基本的东西。这是我的测试用例- def test_silly(self): with self.test_session() as sess: init_op = tf.global_variables_initializer() out = tf.contrib.layers.fully_connected( inputs=tf.zeros([self.batch_size,
def test_silly(self):
with self.test_session() as sess:
init_op = tf.global_variables_initializer()
out = tf.contrib.layers.fully_connected(
inputs=tf.zeros([self.batch_size, 10]),
num_outputs=20,
activation_fn=None,
scope="hmmm")
sess.run(init_op)
print(out.eval())
我不明白为什么我总是得到下面这样的错误
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value hmmm/weights
[[Node: hmmm/weights/read = Identity[T=DT_FLOAT, _class=["loc:@hmmm/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"](hmmm/weights)]]
hmmm/权重
未初始化
def测试(自):
使用self.test_session()作为sess:
out=tf.contrib.layers.fully\u连接(
输入=tf.零([self.batch_size,10]),
num_输出=20,
激活\u fn=无,
scope=“hmmm”)
init_op=tf.global_variables_initializer()
sess.run(初始化操作)
打印(out.eval())
交换
init_op
的位置将使其工作。有关详细信息,请参阅。谢谢!很高兴知道