TensorFlow测试精度为1,所有SoftMax值为0.5

时间:2016-09-07 16:12:25

标签: numpy tensorflow softmax

我在TensorFlow示例中交换了自己的数据来代替MNIST数据,其中我有2d数组作为我的模型输入(x),即:

[[379 1] [412 2] ... [205 1] [504 8]]

和1d输出(y),即:

[20, 24, ... 19, 27]

以下代码为所有训练步骤生成2d数组[0.5, 0.5],为测试数据生成1(对于测试数据随机生成时)。此外,所有权重和偏差均为零。

for i in range(10):
  print 'iterator:'
  print i
  batch_ys = np.reshape(training_outputs, (300, 1))

  ## batch_xs.shape = (300, 2)
  batch_xs = training_inputs

  sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})

  print 'softmax value'
  ## !! these are a all [ 0.5  0.5]  !!
  print(sess.run(y, feed_dict={x: batch_xs}))

correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))

accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

test_outputs = np.random.rand(300, 1)

## the following prints 1
print(sess.run(accuracy, feed_dict={x: test_inputs, y_: test_outputs}))

我从根本上错过了一些东西吗?

0 个答案:

没有答案