ValueError: Cannot feed value of shape (100,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)'












1














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}))









share|improve this question



























    1














    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}))









    share|improve this question

























      1












      1








      1







      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}))









      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 13:42









      Jack Zhang

      62




      62





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini