pychrm代码问题

img
文件显示的是没有错误

img
但是运行后出现这个错误,tensorflow我也下载了
怎么解决啊

错误消息不全。根据最后这个提示应该是有对象没有成功创建,还是None,你可以排查一下。


import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
Mnist = input_data.read_data_sets("data/", one_hot=True)
Display(mnist.train.images.shape)
Display(mnist.train.labels.shape)
Plt.imshow(mnist.train.images[1].reshape(28, 28), cmap="gray")
X = tf.placehnlder(dtype=tf.float32,  shape=[None,  784])
y = tf.placeholder(dtype=tf.float32,  shape=[None,  10])
W = tf.Variable(tf.zeros(shape=[784,  10]))
b = tf.Variable(tf.zeros(shape=[1,  10]))
z = tf.matmul(X,  W) + b
a = tf.nn.softmax(z)
Loss = tf.reduce_sum(y * tf.log(a))
train_step = tf.train.GradientDescentoptimizer(0.01).minimize(loss)
correct = tf.equal(tf.argmax(y, axis=1), tf.argnax(a, axis=1))
rate = tf.reduce_mean(tf.cast(correct, tf.float32))
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for i in range(3000):
        batch_X, batch_y = mnist.train.next_batch(100)
        sess.run(train_step, feed_dict={X: batch_X, y: batch_y})
        if i % 500 == 0:
            Print(sess.run(rate, feed_dict={X: mnist.test.image, y: mnist.test.labels}))
这是我的代码,作用是手写数字识别