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)'
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
add a comment |
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
add a comment |
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
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
python tensorflow logistic-regression tensorboard mnist
asked Mar 7 at 17:09
Code_ArtCode_Art
328
328
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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)
add a comment |
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
);
);
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%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
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)
add a comment |
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)
add a comment |
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)
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)
answered Mar 8 at 22:45
MPękalskiMPękalski
2,07011628
2,07011628
add a comment |
add a comment |
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.
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%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
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