【发布时间】:2018-04-21 09:12:32
【问题描述】:
以下代码部分的最后一行有错误:
confusionMatrix = tf.confusion_matrix(labels=y_true_cls,predictions=y_pred_cls)
x_batch, y_batch, _, cls_batch = data.valid.next_batch(batch_size_validation)
confusionMatrix = session.run(confusionMatrix, feed_dict={x: x_batch, y_true: y_batch})
错误说明如下:
NameError: name 'session' is not defined
在我的代码末尾(在上述代码部分之后),我有以下内容:
with tf.Session() as session:
init = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
session.run(init)
train( num_iteration=1000)
我该如何解决这个问题?
谢谢。
【问题讨论】:
-
session只能在with块内使用...
标签: python tensorflow