我正在从Tensorflow文档中学习Tensorflow,并且正在尝试实施MNIST,但我一直收到此错误。
# placeholders for the data
x = tf.placeholder(tf.float32, [None, 784])
y = tf.placeholder(tf.float32, [None, 10])
# weights and biases
w = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
# softmax model
activation = tf.nn.softmax_cross_entropy_with_logits(logits = tf.matmul(x, w) + b, labels=y)
# backpropagation
train = tf.train.GradientDescentOptimizer(0.5).minimize(activation)
# creating tensorflow session
s = tf.InteractiveSession()
# i have already initialised the variables
# gradient descent
for i in range(100):
x_bat, y_bat= create_batch(x_train, y_train, size=100)
train_step = s.run(train, feed_dict={x: x_bat, y: y_bat})
这是代码
Conflicting parameter types in implementation of 'userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:': 'void (^ _Nonnull __strong)(void)' vs 'void (^__strong _Nonnull)()'
答案 0 :(得分:0)
问题在于create_batch
函数输出错误的y_bat
形状。最有可能的是,你忘了做一个热门编码。
即,当前y_bat
是整数0..9的[100]
向量,但它应该是0 {1}的[100, 10]
向量。
如果您使用input_data.read_data_sets
函数获取数据,则只需添加one_hot=True
。