#file for inputing the data for testing
from scipy import ndimage
image_file='test.png'
image_data = ndimage.imread(image_file).astype(float)
image_data = image_data.reshape((-1, image_size * image_size)).astype(np.float32)
rst = tf.Graph()
with rst.as_default():
result = tf.matmul(image_data, weights) + biases
picko=tf.nn.softmax(result)
with tf.Session(graph=rst) as rsts:
tf.global_variables_initializer().run()
predictions = rsts.run([picko])
运行上述代码时,我收到以下错误。请向我建议一个解决方案,我无法手动解决它。
ValueError:Fetch 参数不能被解释为张量。(张量张量("Softmax_4:0", shape=(1, 10(, dtype=float32( 不是此图的元素。
试试这段代码。
主要区别在于整个代码使用默认图形,而没有一个使用创建的图形。
#file for inputing the data for testing
from scipy import ndimage
image_file = 'test.png'
image_data = ndimage.imread(image_file).astype(float)
image_data = image_data.reshape((-1, image_size * image_size)).astype(np.float32)
result = tf.matmul(image_data, weights) + biases
picko = tf.nn.softmax(result)
with tf.Session() as rsts:
tf.global_variables_initializer().run()
predictions = rsts.run([picko])