ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'
up vote
1
down vote
favorite
I'm newer to tensorflow, I implement the logistic regression using tensorflow, my code is same as the book "Getting started with TensorFlow", but when I run it, occured error: ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'. Could anyone help me?
mnist = input_data.read_data_sets("tmp/data/", one_hot=False)
# set the total number of epochs of the training phase:
training_epochs = 25
learning_rate = 0.01
batch_size = 100
display_step = 1
# building the model
# define 'x' as the input tensor, it represents the MNIST data
# images of size 28 x 28 = 784 pixels:
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
evidence = tf.matmul(x, W) + b
activation = tf.nn.softmax(evidence)
# error function
cross_entropy = y * tf.lgamma(activation)
# cost function
cost = tf.reduce_mean(-tf.reduce_sum(cross_entropy, reduction_indices = 1))
# minimize the cost function
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
avg_set =
epoch_set =
init = tf.global_variables_initializer()
with tf.Session() as sess:
for epoch in range(training_epochs):
avg_cost = 0
total_batch = int(mnist.train.num_examples / batch_size)
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
# Fit the training using the batch data:
sess.run(optimizer, feed_dict = x: batch_xs, y: batch_ys)
# compute the average loss:
avg_cost += sess.run(cost, feed_dict = x: batch_xs,
y: batch_ys) / total_batch
# During the computation, we display a log per epoch step:
if epoch % display_step == 0:
print("Epoch: ", '%04d' % (epoch + 1),
"cost=", ":.9f".format(avg_cost))
print("Training phase finished.")
correct_prediction = tf.equal(tf.argmax(activation, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print("MODEL accuracy: ", accuracy.eval(x: mnist.test.images,
y: mnist.test.labels))
python tensorflow
add a comment |
up vote
1
down vote
favorite
I'm newer to tensorflow, I implement the logistic regression using tensorflow, my code is same as the book "Getting started with TensorFlow", but when I run it, occured error: ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'. Could anyone help me?
mnist = input_data.read_data_sets("tmp/data/", one_hot=False)
# set the total number of epochs of the training phase:
training_epochs = 25
learning_rate = 0.01
batch_size = 100
display_step = 1
# building the model
# define 'x' as the input tensor, it represents the MNIST data
# images of size 28 x 28 = 784 pixels:
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
evidence = tf.matmul(x, W) + b
activation = tf.nn.softmax(evidence)
# error function
cross_entropy = y * tf.lgamma(activation)
# cost function
cost = tf.reduce_mean(-tf.reduce_sum(cross_entropy, reduction_indices = 1))
# minimize the cost function
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
avg_set =
epoch_set =
init = tf.global_variables_initializer()
with tf.Session() as sess:
for epoch in range(training_epochs):
avg_cost = 0
total_batch = int(mnist.train.num_examples / batch_size)
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
# Fit the training using the batch data:
sess.run(optimizer, feed_dict = x: batch_xs, y: batch_ys)
# compute the average loss:
avg_cost += sess.run(cost, feed_dict = x: batch_xs,
y: batch_ys) / total_batch
# During the computation, we display a log per epoch step:
if epoch % display_step == 0:
print("Epoch: ", '%04d' % (epoch + 1),
"cost=", ":.9f".format(avg_cost))
print("Training phase finished.")
correct_prediction = tf.equal(tf.argmax(activation, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print("MODEL accuracy: ", accuracy.eval(x: mnist.test.images,
y: mnist.test.labels))
python tensorflow
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm newer to tensorflow, I implement the logistic regression using tensorflow, my code is same as the book "Getting started with TensorFlow", but when I run it, occured error: ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'. Could anyone help me?
mnist = input_data.read_data_sets("tmp/data/", one_hot=False)
# set the total number of epochs of the training phase:
training_epochs = 25
learning_rate = 0.01
batch_size = 100
display_step = 1
# building the model
# define 'x' as the input tensor, it represents the MNIST data
# images of size 28 x 28 = 784 pixels:
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
evidence = tf.matmul(x, W) + b
activation = tf.nn.softmax(evidence)
# error function
cross_entropy = y * tf.lgamma(activation)
# cost function
cost = tf.reduce_mean(-tf.reduce_sum(cross_entropy, reduction_indices = 1))
# minimize the cost function
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
avg_set =
epoch_set =
init = tf.global_variables_initializer()
with tf.Session() as sess:
for epoch in range(training_epochs):
avg_cost = 0
total_batch = int(mnist.train.num_examples / batch_size)
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
# Fit the training using the batch data:
sess.run(optimizer, feed_dict = x: batch_xs, y: batch_ys)
# compute the average loss:
avg_cost += sess.run(cost, feed_dict = x: batch_xs,
y: batch_ys) / total_batch
# During the computation, we display a log per epoch step:
if epoch % display_step == 0:
print("Epoch: ", '%04d' % (epoch + 1),
"cost=", ":.9f".format(avg_cost))
print("Training phase finished.")
correct_prediction = tf.equal(tf.argmax(activation, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print("MODEL accuracy: ", accuracy.eval(x: mnist.test.images,
y: mnist.test.labels))
python tensorflow
I'm newer to tensorflow, I implement the logistic regression using tensorflow, my code is same as the book "Getting started with TensorFlow", but when I run it, occured error: ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'. Could anyone help me?
mnist = input_data.read_data_sets("tmp/data/", one_hot=False)
# set the total number of epochs of the training phase:
training_epochs = 25
learning_rate = 0.01
batch_size = 100
display_step = 1
# building the model
# define 'x' as the input tensor, it represents the MNIST data
# images of size 28 x 28 = 784 pixels:
x = tf.placeholder("float", [None, 784])
y = tf.placeholder("float", [None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
evidence = tf.matmul(x, W) + b
activation = tf.nn.softmax(evidence)
# error function
cross_entropy = y * tf.lgamma(activation)
# cost function
cost = tf.reduce_mean(-tf.reduce_sum(cross_entropy, reduction_indices = 1))
# minimize the cost function
optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
avg_set =
epoch_set =
init = tf.global_variables_initializer()
with tf.Session() as sess:
for epoch in range(training_epochs):
avg_cost = 0
total_batch = int(mnist.train.num_examples / batch_size)
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
# Fit the training using the batch data:
sess.run(optimizer, feed_dict = x: batch_xs, y: batch_ys)
# compute the average loss:
avg_cost += sess.run(cost, feed_dict = x: batch_xs,
y: batch_ys) / total_batch
# During the computation, we display a log per epoch step:
if epoch % display_step == 0:
print("Epoch: ", '%04d' % (epoch + 1),
"cost=", ":.9f".format(avg_cost))
print("Training phase finished.")
correct_prediction = tf.equal(tf.argmax(activation, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print("MODEL accuracy: ", accuracy.eval(x: mnist.test.images,
y: mnist.test.labels))
python tensorflow
python tensorflow
asked Nov 11 at 13:42
Jack Zhang
62
62
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249341%2fvalueerror-cannot-feed-value-of-shape-100-for-tensor-placeholder-10-whic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown