Keras with TensorBoard error “InvalidArgumentError: You must feed a value for placeholder tensor”











up vote
0
down vote

favorite












I'm trying to get TensorBoard working with Keras.
It looks like I'm able to run an initial model with tf (1.12.0) and keras (2.1.6-tf). I have some simple code. Listed below:



%matplotlib inline
from io import StringIO

import numpy as np
import pandas as pd
import tensorflow as tf

csv = StringIO('''a,b,c,y
0,1,2,0
1,2,0,1
0,2,1,0
3,2,1,1
3,1,2,0''')
data = pd.read_csv(csv)

def tb_cb(batch_size):
# visualize graphs and grandient
tb = tf.keras.callbacks.TensorBoard(log_dir='/tmp/test/',
histogram_freq=1,
batch_size=batch_size, write_graph=True,
write_grads=True)
return tb

m = tf.keras.Sequential([
# going to change 1 in the line below
tf.keras.layers.Dense(1, activation='relu', input_shape=(3,), name='hidden1'),
tf.keras.layers.Dense(1, activation='linear', name='output')
])
m.compile(loss='mse', optimizer='adam', metrics=['mae'])
X = data.iloc[:,:3]
y = data.y
hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
validation_data=(X,y))


The first time I run this I get TensorBoard output. I have then changed the number of neurons in the hidden layer and re-run the model.



I get the following error:



---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-4e4fb6f60bf0> in <module>
15 y = data.y
16 hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
---> 17 validation_data=(X,y))

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
1637 initial_epoch=initial_epoch,
1638 steps_per_epoch=steps_per_epoch,
-> 1639 validation_steps=validation_steps)
1640
1641 def evaluate(self,

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
231 sample_weights=val_sample_weights,
232 batch_size=batch_size,
--> 233 verbose=0)
234 if not isinstance(val_outs, list):
235 val_outs = [val_outs]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in test_loop(model, inputs, targets, sample_weights, batch_size, verbose, steps)
437 ins_batch[i] = ins_batch[i].toarray()
438
--> 439 batch_outs = f(ins_batch)
440
441 if isinstance(batch_outs, list):

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in __call__(self, inputs)
2984
2985 fetched = self._callable_fn(*array_vals,
-> 2986 run_metadata=self.run_metadata)
2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
2988 return fetched[:len(self.outputs)]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/client/session.py in __call__(self, *args, **kwargs)
1437 ret = tf_session.TF_SessionRunCallable(
1438 self._session._session, self._handle, args, status,
-> 1439 run_metadata_ptr)
1440 if run_metadata:
1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.env/364/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
526 None, None,
527 compat.as_text(c_api.TF_Message(self.status.status)),
--> 528 c_api.TF_GetCode(self.status.status))
529 # Delete the underlying status object from memory otherwise it stays alive
530 # as there is a reference to status from this from the traceback due to

InvalidArgumentError: You must feed a value for placeholder tensor 'dense_9_target' with dtype float and shape [?,?]
[[{{node dense_9_target}} = Placeholder[dtype=DT_FLOAT, shape=[?,?], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]









share|improve this question






















  • what do you changed exactly?
    – Geeocode
    Nov 22 at 17:07















up vote
0
down vote

favorite












I'm trying to get TensorBoard working with Keras.
It looks like I'm able to run an initial model with tf (1.12.0) and keras (2.1.6-tf). I have some simple code. Listed below:



%matplotlib inline
from io import StringIO

import numpy as np
import pandas as pd
import tensorflow as tf

csv = StringIO('''a,b,c,y
0,1,2,0
1,2,0,1
0,2,1,0
3,2,1,1
3,1,2,0''')
data = pd.read_csv(csv)

def tb_cb(batch_size):
# visualize graphs and grandient
tb = tf.keras.callbacks.TensorBoard(log_dir='/tmp/test/',
histogram_freq=1,
batch_size=batch_size, write_graph=True,
write_grads=True)
return tb

m = tf.keras.Sequential([
# going to change 1 in the line below
tf.keras.layers.Dense(1, activation='relu', input_shape=(3,), name='hidden1'),
tf.keras.layers.Dense(1, activation='linear', name='output')
])
m.compile(loss='mse', optimizer='adam', metrics=['mae'])
X = data.iloc[:,:3]
y = data.y
hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
validation_data=(X,y))


The first time I run this I get TensorBoard output. I have then changed the number of neurons in the hidden layer and re-run the model.



I get the following error:



---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-4e4fb6f60bf0> in <module>
15 y = data.y
16 hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
---> 17 validation_data=(X,y))

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
1637 initial_epoch=initial_epoch,
1638 steps_per_epoch=steps_per_epoch,
-> 1639 validation_steps=validation_steps)
1640
1641 def evaluate(self,

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
231 sample_weights=val_sample_weights,
232 batch_size=batch_size,
--> 233 verbose=0)
234 if not isinstance(val_outs, list):
235 val_outs = [val_outs]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in test_loop(model, inputs, targets, sample_weights, batch_size, verbose, steps)
437 ins_batch[i] = ins_batch[i].toarray()
438
--> 439 batch_outs = f(ins_batch)
440
441 if isinstance(batch_outs, list):

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in __call__(self, inputs)
2984
2985 fetched = self._callable_fn(*array_vals,
-> 2986 run_metadata=self.run_metadata)
2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
2988 return fetched[:len(self.outputs)]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/client/session.py in __call__(self, *args, **kwargs)
1437 ret = tf_session.TF_SessionRunCallable(
1438 self._session._session, self._handle, args, status,
-> 1439 run_metadata_ptr)
1440 if run_metadata:
1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.env/364/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
526 None, None,
527 compat.as_text(c_api.TF_Message(self.status.status)),
--> 528 c_api.TF_GetCode(self.status.status))
529 # Delete the underlying status object from memory otherwise it stays alive
530 # as there is a reference to status from this from the traceback due to

InvalidArgumentError: You must feed a value for placeholder tensor 'dense_9_target' with dtype float and shape [?,?]
[[{{node dense_9_target}} = Placeholder[dtype=DT_FLOAT, shape=[?,?], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]









share|improve this question






















  • what do you changed exactly?
    – Geeocode
    Nov 22 at 17:07













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to get TensorBoard working with Keras.
It looks like I'm able to run an initial model with tf (1.12.0) and keras (2.1.6-tf). I have some simple code. Listed below:



%matplotlib inline
from io import StringIO

import numpy as np
import pandas as pd
import tensorflow as tf

csv = StringIO('''a,b,c,y
0,1,2,0
1,2,0,1
0,2,1,0
3,2,1,1
3,1,2,0''')
data = pd.read_csv(csv)

def tb_cb(batch_size):
# visualize graphs and grandient
tb = tf.keras.callbacks.TensorBoard(log_dir='/tmp/test/',
histogram_freq=1,
batch_size=batch_size, write_graph=True,
write_grads=True)
return tb

m = tf.keras.Sequential([
# going to change 1 in the line below
tf.keras.layers.Dense(1, activation='relu', input_shape=(3,), name='hidden1'),
tf.keras.layers.Dense(1, activation='linear', name='output')
])
m.compile(loss='mse', optimizer='adam', metrics=['mae'])
X = data.iloc[:,:3]
y = data.y
hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
validation_data=(X,y))


The first time I run this I get TensorBoard output. I have then changed the number of neurons in the hidden layer and re-run the model.



I get the following error:



---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-4e4fb6f60bf0> in <module>
15 y = data.y
16 hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
---> 17 validation_data=(X,y))

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
1637 initial_epoch=initial_epoch,
1638 steps_per_epoch=steps_per_epoch,
-> 1639 validation_steps=validation_steps)
1640
1641 def evaluate(self,

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
231 sample_weights=val_sample_weights,
232 batch_size=batch_size,
--> 233 verbose=0)
234 if not isinstance(val_outs, list):
235 val_outs = [val_outs]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in test_loop(model, inputs, targets, sample_weights, batch_size, verbose, steps)
437 ins_batch[i] = ins_batch[i].toarray()
438
--> 439 batch_outs = f(ins_batch)
440
441 if isinstance(batch_outs, list):

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in __call__(self, inputs)
2984
2985 fetched = self._callable_fn(*array_vals,
-> 2986 run_metadata=self.run_metadata)
2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
2988 return fetched[:len(self.outputs)]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/client/session.py in __call__(self, *args, **kwargs)
1437 ret = tf_session.TF_SessionRunCallable(
1438 self._session._session, self._handle, args, status,
-> 1439 run_metadata_ptr)
1440 if run_metadata:
1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.env/364/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
526 None, None,
527 compat.as_text(c_api.TF_Message(self.status.status)),
--> 528 c_api.TF_GetCode(self.status.status))
529 # Delete the underlying status object from memory otherwise it stays alive
530 # as there is a reference to status from this from the traceback due to

InvalidArgumentError: You must feed a value for placeholder tensor 'dense_9_target' with dtype float and shape [?,?]
[[{{node dense_9_target}} = Placeholder[dtype=DT_FLOAT, shape=[?,?], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]









share|improve this question













I'm trying to get TensorBoard working with Keras.
It looks like I'm able to run an initial model with tf (1.12.0) and keras (2.1.6-tf). I have some simple code. Listed below:



%matplotlib inline
from io import StringIO

import numpy as np
import pandas as pd
import tensorflow as tf

csv = StringIO('''a,b,c,y
0,1,2,0
1,2,0,1
0,2,1,0
3,2,1,1
3,1,2,0''')
data = pd.read_csv(csv)

def tb_cb(batch_size):
# visualize graphs and grandient
tb = tf.keras.callbacks.TensorBoard(log_dir='/tmp/test/',
histogram_freq=1,
batch_size=batch_size, write_graph=True,
write_grads=True)
return tb

m = tf.keras.Sequential([
# going to change 1 in the line below
tf.keras.layers.Dense(1, activation='relu', input_shape=(3,), name='hidden1'),
tf.keras.layers.Dense(1, activation='linear', name='output')
])
m.compile(loss='mse', optimizer='adam', metrics=['mae'])
X = data.iloc[:,:3]
y = data.y
hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
validation_data=(X,y))


The first time I run this I get TensorBoard output. I have then changed the number of neurons in the hidden layer and re-run the model.



I get the following error:



---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-4e4fb6f60bf0> in <module>
15 y = data.y
16 hist = m.fit(X, y, epochs=10, verbose=1, callbacks=[tb_cb(10)],
---> 17 validation_data=(X,y))

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, max_queue_size, workers, use_multiprocessing, **kwargs)
1637 initial_epoch=initial_epoch,
1638 steps_per_epoch=steps_per_epoch,
-> 1639 validation_steps=validation_steps)
1640
1641 def evaluate(self,

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in fit_loop(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps)
231 sample_weights=val_sample_weights,
232 batch_size=batch_size,
--> 233 verbose=0)
234 if not isinstance(val_outs, list):
235 val_outs = [val_outs]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_arrays.py in test_loop(model, inputs, targets, sample_weights, batch_size, verbose, steps)
437 ins_batch[i] = ins_batch[i].toarray()
438
--> 439 batch_outs = f(ins_batch)
440
441 if isinstance(batch_outs, list):

~/.env/364/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in __call__(self, inputs)
2984
2985 fetched = self._callable_fn(*array_vals,
-> 2986 run_metadata=self.run_metadata)
2987 self._call_fetch_callbacks(fetched[-len(self._fetches):])
2988 return fetched[:len(self.outputs)]

~/.env/364/lib/python3.6/site-packages/tensorflow/python/client/session.py in __call__(self, *args, **kwargs)
1437 ret = tf_session.TF_SessionRunCallable(
1438 self._session._session, self._handle, args, status,
-> 1439 run_metadata_ptr)
1440 if run_metadata:
1441 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/.env/364/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
526 None, None,
527 compat.as_text(c_api.TF_Message(self.status.status)),
--> 528 c_api.TF_GetCode(self.status.status))
529 # Delete the underlying status object from memory otherwise it stays alive
530 # as there is a reference to status from this from the traceback due to

InvalidArgumentError: You must feed a value for placeholder tensor 'dense_9_target' with dtype float and shape [?,?]
[[{{node dense_9_target}} = Placeholder[dtype=DT_FLOAT, shape=[?,?], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]






tensorflow keras tensorboard






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 15:16









matt harrison

46229




46229












  • what do you changed exactly?
    – Geeocode
    Nov 22 at 17:07


















  • what do you changed exactly?
    – Geeocode
    Nov 22 at 17:07
















what do you changed exactly?
– Geeocode
Nov 22 at 17:07




what do you changed exactly?
– Geeocode
Nov 22 at 17:07

















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',
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%2f53433926%2fkeras-with-tensorboard-error-invalidargumenterror-you-must-feed-a-value-for-pl%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%2f53433926%2fkeras-with-tensorboard-error-invalidargumenterror-you-must-feed-a-value-for-pl%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

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo