下面是张量流中的二元分类器。它总是预测1,因此报告100%的准确性。有人可以解释我哪里出错了吗?
def mlp(curr_data_batch, y1, i, ep):
with tf.variable_scope("name"+str(i), reuse=True):
b = tf.get_variable("bias")
W = tf.get_variable("weights")
y = tf.nn.softmax(tf.matmul(x,W) + b)
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y),
reduction_indices=[1]))
train_op = tf.train.GradientDescentOptimizer(learning_rate
).minimize(cross_entropy)
sess.run([train_op, y], feed_dict={x: curr_data_batch, y_: y1})
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print i, ep, ("Accuracy:", accuracy.eval({x: curr_data_batch, y_:
y1}, session=sess))
编辑:我刚刚看到权重没有得到更新。它是否因可变范围而发生?