How to write summary log using tensorflow for logistic regression on MNIST data?2019 Community Moderator ElectionHow do I write JSON data to a file?Tensorflow: how to save/restore a model?How can I test own image to Cifar-10 tutorial on Tensorflow?Simple Feedforward Neural Network with TensorFlow won't learnInvalidArgumentError while coding MNIST tutorialSpeed of Logistic Regression on MNIST with TensorflowTensorflow/board: Shape [-1,784] has negative dimensionTensorflow: logistic regression to mnisttflite outputs don't match with tensorflow outputs for conv2d_transposeValueError: Cannot feed value of shape (4,) for Tensor 'Placeholder_36:0', which has shape '(?, 4)'

Do I need to be arrogant to get ahead?

Geography in 3D perspective

In Aliens, how many people were on LV-426 before the Marines arrived​?

Are dual Irish/British citizens bound by the 90/180 day rule when travelling in the EU after Brexit?

Brake pads destroying wheels

How could an airship be repaired midflight?

Is it insecure to send a password in a `curl` command?

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

What does Jesus mean regarding "Raca," and "you fool?" - is he contrasting them?

What is the term when voters “dishonestly” choose something that they do not want to choose?

Writing in a Christian voice

Do native speakers use "ultima" and "proxima" frequently in spoken English?

Synchronized implementation of a bank account in Java

Is there a creature that is resistant or immune to non-magical damage other than bludgeoning, slashing, and piercing?

Have the tides ever turned twice on any open problem?

Suggestions on how to spend Shaabath (constructively) alone

Why are there no stars visible in cislunar space?

Practical application of matrices and determinants

Unfrosted light bulb

Would it be believable to defy demographics in a story?

What is the significance behind "40 days" that often appears in the Bible?

Help rendering a complicated sum/product formula

Fewest number of steps to reach 200 using special calculator

Probably overheated black color SMD pads



How to write summary log using tensorflow for logistic regression on MNIST data?



2019 Community Moderator ElectionHow do I write JSON data to a file?Tensorflow: how to save/restore a model?How can I test own image to Cifar-10 tutorial on Tensorflow?Simple Feedforward Neural Network with TensorFlow won't learnInvalidArgumentError while coding MNIST tutorialSpeed of Logistic Regression on MNIST with TensorflowTensorflow/board: Shape [-1,784] has negative dimensionTensorflow: logistic regression to mnisttflite outputs don't match with tensorflow outputs for conv2d_transposeValueError: Cannot feed value of shape (4,) for Tensor 'Placeholder_36:0', which has shape '(?, 4)'










2















I am new with tensorflow and implementation of tensorboard. This is my very first experience to implement logistic regression on MNIST data using tensorflow. I have successfully implemented logistic regression on data and now I am trying to log summary to log file using tf.summary .fileWriter.



Here is my code which affects the summary parameter



x = tf.placeholder(dtype=tf.float32, shape=(None, 784))
y = tf.placeholder(dtype=tf.float32, shape=(None, 10))

loss_op = tf.losses.mean_squared_error(y, pred)
correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

tf.summary.scalar("loss", loss_op)
tf.summary.scalar("training_accuracy", accuracy_op)
summary_op = tf.summary.merge_all()


And this is how I am training my model



with tf.Session() as sess: 
sess.run(init)
writer = tf.summary.FileWriter('./graphs', sess.graph)

for iter in range(50):
batch_x, batch_y = mnist.train.next_batch(batch_size)
_, loss, tr_acc,summary = sess.run([optimizer_op, loss_op, accuracy_op, summary_op], feed_dict=x: batch_x, y: batch_y)
summary = sess.run(summary_op, feed_dict=x: batch_x, y: batch_y)
writer.add_summary(summary, iter)


After adding the summary line to get merged summary, I am getting below error




InvalidArgumentError (see above for traceback):
You must feed a value for placeholder tensor 'Placeholder_37'
with dtype float and shape [?,10]



This error points to the declaration of Y



y = tf.placeholder(dtype=tf.float32, shape=(None, 10)) 


Can you please help me what I am doing wrong?










share|improve this question


























    2















    I am new with tensorflow and implementation of tensorboard. This is my very first experience to implement logistic regression on MNIST data using tensorflow. I have successfully implemented logistic regression on data and now I am trying to log summary to log file using tf.summary .fileWriter.



    Here is my code which affects the summary parameter



    x = tf.placeholder(dtype=tf.float32, shape=(None, 784))
    y = tf.placeholder(dtype=tf.float32, shape=(None, 10))

    loss_op = tf.losses.mean_squared_error(y, pred)
    correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
    accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

    tf.summary.scalar("loss", loss_op)
    tf.summary.scalar("training_accuracy", accuracy_op)
    summary_op = tf.summary.merge_all()


    And this is how I am training my model



    with tf.Session() as sess: 
    sess.run(init)
    writer = tf.summary.FileWriter('./graphs', sess.graph)

    for iter in range(50):
    batch_x, batch_y = mnist.train.next_batch(batch_size)
    _, loss, tr_acc,summary = sess.run([optimizer_op, loss_op, accuracy_op, summary_op], feed_dict=x: batch_x, y: batch_y)
    summary = sess.run(summary_op, feed_dict=x: batch_x, y: batch_y)
    writer.add_summary(summary, iter)


    After adding the summary line to get merged summary, I am getting below error




    InvalidArgumentError (see above for traceback):
    You must feed a value for placeholder tensor 'Placeholder_37'
    with dtype float and shape [?,10]



    This error points to the declaration of Y



    y = tf.placeholder(dtype=tf.float32, shape=(None, 10)) 


    Can you please help me what I am doing wrong?










    share|improve this question
























      2












      2








      2








      I am new with tensorflow and implementation of tensorboard. This is my very first experience to implement logistic regression on MNIST data using tensorflow. I have successfully implemented logistic regression on data and now I am trying to log summary to log file using tf.summary .fileWriter.



      Here is my code which affects the summary parameter



      x = tf.placeholder(dtype=tf.float32, shape=(None, 784))
      y = tf.placeholder(dtype=tf.float32, shape=(None, 10))

      loss_op = tf.losses.mean_squared_error(y, pred)
      correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
      accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

      tf.summary.scalar("loss", loss_op)
      tf.summary.scalar("training_accuracy", accuracy_op)
      summary_op = tf.summary.merge_all()


      And this is how I am training my model



      with tf.Session() as sess: 
      sess.run(init)
      writer = tf.summary.FileWriter('./graphs', sess.graph)

      for iter in range(50):
      batch_x, batch_y = mnist.train.next_batch(batch_size)
      _, loss, tr_acc,summary = sess.run([optimizer_op, loss_op, accuracy_op, summary_op], feed_dict=x: batch_x, y: batch_y)
      summary = sess.run(summary_op, feed_dict=x: batch_x, y: batch_y)
      writer.add_summary(summary, iter)


      After adding the summary line to get merged summary, I am getting below error




      InvalidArgumentError (see above for traceback):
      You must feed a value for placeholder tensor 'Placeholder_37'
      with dtype float and shape [?,10]



      This error points to the declaration of Y



      y = tf.placeholder(dtype=tf.float32, shape=(None, 10)) 


      Can you please help me what I am doing wrong?










      share|improve this question














      I am new with tensorflow and implementation of tensorboard. This is my very first experience to implement logistic regression on MNIST data using tensorflow. I have successfully implemented logistic regression on data and now I am trying to log summary to log file using tf.summary .fileWriter.



      Here is my code which affects the summary parameter



      x = tf.placeholder(dtype=tf.float32, shape=(None, 784))
      y = tf.placeholder(dtype=tf.float32, shape=(None, 10))

      loss_op = tf.losses.mean_squared_error(y, pred)
      correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
      accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

      tf.summary.scalar("loss", loss_op)
      tf.summary.scalar("training_accuracy", accuracy_op)
      summary_op = tf.summary.merge_all()


      And this is how I am training my model



      with tf.Session() as sess: 
      sess.run(init)
      writer = tf.summary.FileWriter('./graphs', sess.graph)

      for iter in range(50):
      batch_x, batch_y = mnist.train.next_batch(batch_size)
      _, loss, tr_acc,summary = sess.run([optimizer_op, loss_op, accuracy_op, summary_op], feed_dict=x: batch_x, y: batch_y)
      summary = sess.run(summary_op, feed_dict=x: batch_x, y: batch_y)
      writer.add_summary(summary, iter)


      After adding the summary line to get merged summary, I am getting below error




      InvalidArgumentError (see above for traceback):
      You must feed a value for placeholder tensor 'Placeholder_37'
      with dtype float and shape [?,10]



      This error points to the declaration of Y



      y = tf.placeholder(dtype=tf.float32, shape=(None, 10)) 


      Can you please help me what I am doing wrong?







      python tensorflow logistic-regression tensorboard mnist






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 17:09









      Code_ArtCode_Art

      328




      328






















          1 Answer
          1






          active

          oldest

          votes


















          0














          From the error message it looks like you are running your code in some kind of jupyter environment. Try restarting the kernel/runtime and run everything again. Running the code twice in graph mode does not work in jupyter well. If I run my code, below, first time it does not return any errors, when I run it second time (w/o restarting kernel/runtime) then it crashes the same way as yours does.



          I was too lazy to check it on actual model so my pred=y. ;)
          But the code below does not crash, so you should be able to adapt it to your needs. I've tested it in Google Colab.



          import tensorflow as tf
          from tensorflow.examples.tutorials.mnist import input_data
          mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

          x = tf.placeholder(dtype=tf.float32, shape=(None, 784), name='x-input')
          y = tf.placeholder(dtype=tf.float32, shape=(None, 10), name='y-input')

          pred = y
          loss_op = tf.losses.mean_squared_error(y, pred)
          correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
          accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

          with tf.name_scope('summaries'):
          tf.summary.scalar("loss", loss_op, collections=["train_summary"])
          tf.summary.scalar("training_accuracy", accuracy_op, collections=["train_summary"])

          with tf.Session() as sess:
          summary_op = tf.summary.merge_all(key='train_summary')
          train_writer = tf.summary.FileWriter('./graphs', sess.graph)
          sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

          for iter in range(50):
          batch_x, batch_y = mnist.train.next_batch(1)
          loss, acc, summary = sess.run([loss_op, accuracy_op, summary_op], feed_dict=x:batch_x, y:batch_y)
          train_writer.add_summary(summary, iter)





          share|improve this answer






















            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%2f55049376%2fhow-to-write-summary-log-using-tensorflow-for-logistic-regression-on-mnist-data%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            From the error message it looks like you are running your code in some kind of jupyter environment. Try restarting the kernel/runtime and run everything again. Running the code twice in graph mode does not work in jupyter well. If I run my code, below, first time it does not return any errors, when I run it second time (w/o restarting kernel/runtime) then it crashes the same way as yours does.



            I was too lazy to check it on actual model so my pred=y. ;)
            But the code below does not crash, so you should be able to adapt it to your needs. I've tested it in Google Colab.



            import tensorflow as tf
            from tensorflow.examples.tutorials.mnist import input_data
            mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

            x = tf.placeholder(dtype=tf.float32, shape=(None, 784), name='x-input')
            y = tf.placeholder(dtype=tf.float32, shape=(None, 10), name='y-input')

            pred = y
            loss_op = tf.losses.mean_squared_error(y, pred)
            correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
            accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

            with tf.name_scope('summaries'):
            tf.summary.scalar("loss", loss_op, collections=["train_summary"])
            tf.summary.scalar("training_accuracy", accuracy_op, collections=["train_summary"])

            with tf.Session() as sess:
            summary_op = tf.summary.merge_all(key='train_summary')
            train_writer = tf.summary.FileWriter('./graphs', sess.graph)
            sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

            for iter in range(50):
            batch_x, batch_y = mnist.train.next_batch(1)
            loss, acc, summary = sess.run([loss_op, accuracy_op, summary_op], feed_dict=x:batch_x, y:batch_y)
            train_writer.add_summary(summary, iter)





            share|improve this answer



























              0














              From the error message it looks like you are running your code in some kind of jupyter environment. Try restarting the kernel/runtime and run everything again. Running the code twice in graph mode does not work in jupyter well. If I run my code, below, first time it does not return any errors, when I run it second time (w/o restarting kernel/runtime) then it crashes the same way as yours does.



              I was too lazy to check it on actual model so my pred=y. ;)
              But the code below does not crash, so you should be able to adapt it to your needs. I've tested it in Google Colab.



              import tensorflow as tf
              from tensorflow.examples.tutorials.mnist import input_data
              mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

              x = tf.placeholder(dtype=tf.float32, shape=(None, 784), name='x-input')
              y = tf.placeholder(dtype=tf.float32, shape=(None, 10), name='y-input')

              pred = y
              loss_op = tf.losses.mean_squared_error(y, pred)
              correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
              accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

              with tf.name_scope('summaries'):
              tf.summary.scalar("loss", loss_op, collections=["train_summary"])
              tf.summary.scalar("training_accuracy", accuracy_op, collections=["train_summary"])

              with tf.Session() as sess:
              summary_op = tf.summary.merge_all(key='train_summary')
              train_writer = tf.summary.FileWriter('./graphs', sess.graph)
              sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

              for iter in range(50):
              batch_x, batch_y = mnist.train.next_batch(1)
              loss, acc, summary = sess.run([loss_op, accuracy_op, summary_op], feed_dict=x:batch_x, y:batch_y)
              train_writer.add_summary(summary, iter)





              share|improve this answer

























                0












                0








                0







                From the error message it looks like you are running your code in some kind of jupyter environment. Try restarting the kernel/runtime and run everything again. Running the code twice in graph mode does not work in jupyter well. If I run my code, below, first time it does not return any errors, when I run it second time (w/o restarting kernel/runtime) then it crashes the same way as yours does.



                I was too lazy to check it on actual model so my pred=y. ;)
                But the code below does not crash, so you should be able to adapt it to your needs. I've tested it in Google Colab.



                import tensorflow as tf
                from tensorflow.examples.tutorials.mnist import input_data
                mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

                x = tf.placeholder(dtype=tf.float32, shape=(None, 784), name='x-input')
                y = tf.placeholder(dtype=tf.float32, shape=(None, 10), name='y-input')

                pred = y
                loss_op = tf.losses.mean_squared_error(y, pred)
                correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
                accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

                with tf.name_scope('summaries'):
                tf.summary.scalar("loss", loss_op, collections=["train_summary"])
                tf.summary.scalar("training_accuracy", accuracy_op, collections=["train_summary"])

                with tf.Session() as sess:
                summary_op = tf.summary.merge_all(key='train_summary')
                train_writer = tf.summary.FileWriter('./graphs', sess.graph)
                sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

                for iter in range(50):
                batch_x, batch_y = mnist.train.next_batch(1)
                loss, acc, summary = sess.run([loss_op, accuracy_op, summary_op], feed_dict=x:batch_x, y:batch_y)
                train_writer.add_summary(summary, iter)





                share|improve this answer













                From the error message it looks like you are running your code in some kind of jupyter environment. Try restarting the kernel/runtime and run everything again. Running the code twice in graph mode does not work in jupyter well. If I run my code, below, first time it does not return any errors, when I run it second time (w/o restarting kernel/runtime) then it crashes the same way as yours does.



                I was too lazy to check it on actual model so my pred=y. ;)
                But the code below does not crash, so you should be able to adapt it to your needs. I've tested it in Google Colab.



                import tensorflow as tf
                from tensorflow.examples.tutorials.mnist import input_data
                mnist = input_data.read_data_sets('MNIST_data', one_hot=True)

                x = tf.placeholder(dtype=tf.float32, shape=(None, 784), name='x-input')
                y = tf.placeholder(dtype=tf.float32, shape=(None, 10), name='y-input')

                pred = y
                loss_op = tf.losses.mean_squared_error(y, pred)
                correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1))
                accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

                with tf.name_scope('summaries'):
                tf.summary.scalar("loss", loss_op, collections=["train_summary"])
                tf.summary.scalar("training_accuracy", accuracy_op, collections=["train_summary"])

                with tf.Session() as sess:
                summary_op = tf.summary.merge_all(key='train_summary')
                train_writer = tf.summary.FileWriter('./graphs', sess.graph)
                sess.run([tf.global_variables_initializer(),tf.local_variables_initializer()])

                for iter in range(50):
                batch_x, batch_y = mnist.train.next_batch(1)
                loss, acc, summary = sess.run([loss_op, accuracy_op, summary_op], feed_dict=x:batch_x, y:batch_y)
                train_writer.add_summary(summary, iter)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 22:45









                MPękalskiMPękalski

                2,07011628




                2,07011628





























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55049376%2fhow-to-write-summary-log-using-tensorflow-for-logistic-regression-on-mnist-data%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







                    Popular posts from this blog

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived