我想用我自己的數據使用這個(https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/multilayer_perceptron.py)教程,但無法使它工作。我的數據是[1X10]大小的矢量。教程是關於MNIST數據的,我試圖用不同類型的向量來提供系統。如何在使用我自己的數據使用張量流時決定批量大小?
我收到錯誤:
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (0, 1) for Tensor u'Placeholder_1:0',
which has shape '(?, 2)'
錯誤從batch_x和batch_y出現,但我無法弄清楚如何決定他們。我會很感激每個想法來解決這個問題。由於
# Training cycle
for epoch in range(training_epochs):
avg_cost = 0.
total_batch = int(train_data.shape[0]/batch_size)
# Loop over all batches
for i in range(total_batch):
batch_x = train_data[:i*batch_size]
batch_y = train_labels[:i*batch_size]
np.reshape(batch_x, (-1, 10))
np.reshape(batch_y, (-1, 1))
# Run optimization op (backprop) and cost op (to get loss value)
_, c = sess.run([optimizer, cost], feed_dict={x: batch_x,
y: batch_y})
# Compute average loss
avg_cost += c/total_batch
# Display logs per epoch step
if epoch % display_step == 0:
print("Epoch:", '%04d' % (epoch+1), "cost=", \
"{:.9f}".format(avg_cost))
print("Optimization Finished!")