In feeding batch_xs to x, I reshaped batch_xs, for BATCH_SIZE is 1. Here is my source. I'm not sure what is making the ValueError.
with tf.name_scope("input") as scope:
x = tf.placeholder(tf.float32, shape=[1, 784])
BATCH_SIZE = 1
DROP_OUT_RATE = 0.4
EPOCH = 1
MEMORIZE = 10
accuracy_array = []
loss = tf.nn.l2_loss(y - x) / BATCH_SIZE
train_step = tf.train.AdamOptimizer(1e-4).minimize(loss)
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
mnist_list = make_mnist_train_list(55000, 10)
test_list = make_mnist_test_list(5000, 10)
sess = tf.Session()
sess.run(tf.initialize_all_variables())
for i in range(EPOCH):
for j in range(5500/BATCH_SIZE):
batch_xs = tf.reshape(mnist_list[0][j*BATCH_SIZE:j*BATCH_SIZE+1], [1, 784])
sess.run(train_step, feed_dict={x: batch_xs, keep_prob: (1.0 - DROP_OUT_RATE), r_keep_prob: (1.0 - DROP_OUT_RATE)})
if (i +1)% MEMORIZE == 0:
accuracy_array.append(loss.eval(session=sess, feed_dict={x: batch_xs, keep_prob: 1.0, r_keep_prob: 1.0}))
print(accuracy_array[ int(math.floor((i+1)/MEMORIZE -1))])
This gives me the Value error, which doesn't make sense to me.
ValueError: Argument must be a dense tensor