Tensorflow logistic regression Iris dataset (csv), Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'Tensorflow - You must feed a value for placeholder tensor 'X' with dtype floaterror in executing sess.run()Attempted to use a closed SessionError when calling global_variables_initializer in TensorFlowTensorflow error ''Cannot feed value of shape (4, 1) for Tensor 'input:0', which has shape '(?, 2)'''ValueError: Cannot feed value of shape (2, 1000, 1) for Tensor 'Placeholder:0', which has shape '(?, 2)'Passing input tensor size to via tensorflow pipelineBug related to tf.sparse_tensor_dense_matmul()Tensorflow Estimator predict Signature and saving/loadingA shape error in a simple cnn text classfication
Is it improper etiquette to ask your opponent what his/her rating is before the game?
Fear of getting stuck on one programming language / technology that is not used in my country
Travelling outside the UK without a passport
Redundant comparison & "if" before assignment
Why did the Mercure fail?
Is it possible to have a strip of cold climate in the middle of a planet?
Open a doc from terminal, but not by its name
What if a revenant (monster) gains fire resistance?
Pre-mixing cryogenic fuels and using only one fuel tank
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
Aragorn's "guise" in the Orthanc Stone
How to indicate a cut out for a product window
Is there a name for this algorithm to calculate the concentration of a mixture of two solutions containing the same solute?
Delivering sarcasm
Approximating irrational number to rational number
Calculating Wattage for Resistor in High Frequency Application?
why `nmap 192.168.1.97` returns less services than `nmap 127.0.0.1`?
Why is it that I can sometimes guess the next note?
Should I stop contributing to retirement accounts?
GraphicsGrid with a Label for each Column and Row
What are the purposes of autoencoders?
Why electric field inside a cavity of a non-conducting sphere not zero?
Lowest total scrabble score
Creature in Shazam mid-credits scene?
Tensorflow logistic regression Iris dataset (csv), Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'
Tensorflow - You must feed a value for placeholder tensor 'X' with dtype floaterror in executing sess.run()Attempted to use a closed SessionError when calling global_variables_initializer in TensorFlowTensorflow error ''Cannot feed value of shape (4, 1) for Tensor 'input:0', which has shape '(?, 2)'''ValueError: Cannot feed value of shape (2, 1000, 1) for Tensor 'Placeholder:0', which has shape '(?, 2)'Passing input tensor size to via tensorflow pipelineBug related to tf.sparse_tensor_dense_matmul()Tensorflow Estimator predict Signature and saving/loadingA shape error in a simple cnn text classfication
I am trying to perform logistic regression on the iris dataset that I got from here, i am using tensorflow and i feel it is giving me the error in the feed_dict part of the error line.
I tried changing the shape of the the x_input and y_input according to the error that occurred using np.reshape() but it didn't help.
#training data
x_input=data.loc[0:105, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
temp=data['FLOWER']
y_input=temp[0:106]
#test data
x_test=data.loc[106:149, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
y_test=temp[106:150]
#placeholders and variables. input has 4 features and output has 3 classes
x=tf.placeholder(tf.float32,shape=[None, 4])
y_=tf.placeholder(tf.float32,shape=[None, 3])
#weight and bias
W=tf.Variable(tf.zeros([4,3]))
b=tf.Variable(tf.zeros([3]))
# X is placeholdre for iris features. We will feed data later on
X = tf.placeholder(tf.float32, [None, 4])
# y is placeholder for iris labels. We will feed data later on
Y = tf.placeholder(tf.float32, [3, None])
w = tf.Variable(tf.zeros([4,3]))
b = tf.Variable(tf.zeros([3]))
# model
#softmax function for multiclass classification
y = tf.nn.softmax(tf.matmul(x, W) + b)
#loss function
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
#optimiser -
train_step = tf.train.AdamOptimizer(0.01).minimize(cross_entropy)
#calculating accuracy of our model
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
#session parameters
sess = tf.InteractiveSession()
#initialising variables
init = tf.initialize_all_variables()
sess.run(init)
#number of interations
epochs=2000
for step in range(epochs):
_, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix()) #error line
if step%500==0:
print(c)
Error stack looks like this
ValueError Traceback (most recent call last)
<ipython-input-13-aa781a046f65> in <module>
1 for step in range(epochs):
----> 2 _, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix())
3 if step%500==0:
4 print(c)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in run(self, fetches, feed_dict, options, run_metadata)
893 try:
894 result = self._run(None, fetches, feed_dict, options_ptr,
--> 895 run_metadata_ptr)
896 if run_metadata:
897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1102 'Cannot feed value of shape %r for Tensor %r, '
1103 'which has shape %r'
-> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1105 if not self.graph.is_feedable(subfeed_t):
1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'
python tensorflow logistic-regression
add a comment |
I am trying to perform logistic regression on the iris dataset that I got from here, i am using tensorflow and i feel it is giving me the error in the feed_dict part of the error line.
I tried changing the shape of the the x_input and y_input according to the error that occurred using np.reshape() but it didn't help.
#training data
x_input=data.loc[0:105, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
temp=data['FLOWER']
y_input=temp[0:106]
#test data
x_test=data.loc[106:149, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
y_test=temp[106:150]
#placeholders and variables. input has 4 features and output has 3 classes
x=tf.placeholder(tf.float32,shape=[None, 4])
y_=tf.placeholder(tf.float32,shape=[None, 3])
#weight and bias
W=tf.Variable(tf.zeros([4,3]))
b=tf.Variable(tf.zeros([3]))
# X is placeholdre for iris features. We will feed data later on
X = tf.placeholder(tf.float32, [None, 4])
# y is placeholder for iris labels. We will feed data later on
Y = tf.placeholder(tf.float32, [3, None])
w = tf.Variable(tf.zeros([4,3]))
b = tf.Variable(tf.zeros([3]))
# model
#softmax function for multiclass classification
y = tf.nn.softmax(tf.matmul(x, W) + b)
#loss function
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
#optimiser -
train_step = tf.train.AdamOptimizer(0.01).minimize(cross_entropy)
#calculating accuracy of our model
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
#session parameters
sess = tf.InteractiveSession()
#initialising variables
init = tf.initialize_all_variables()
sess.run(init)
#number of interations
epochs=2000
for step in range(epochs):
_, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix()) #error line
if step%500==0:
print(c)
Error stack looks like this
ValueError Traceback (most recent call last)
<ipython-input-13-aa781a046f65> in <module>
1 for step in range(epochs):
----> 2 _, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix())
3 if step%500==0:
4 print(c)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in run(self, fetches, feed_dict, options, run_metadata)
893 try:
894 result = self._run(None, fetches, feed_dict, options_ptr,
--> 895 run_metadata_ptr)
896 if run_metadata:
897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1102 'Cannot feed value of shape %r for Tensor %r, '
1103 'which has shape %r'
-> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1105 if not self.graph.is_feedable(subfeed_t):
1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'
python tensorflow logistic-regression
add a comment |
I am trying to perform logistic regression on the iris dataset that I got from here, i am using tensorflow and i feel it is giving me the error in the feed_dict part of the error line.
I tried changing the shape of the the x_input and y_input according to the error that occurred using np.reshape() but it didn't help.
#training data
x_input=data.loc[0:105, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
temp=data['FLOWER']
y_input=temp[0:106]
#test data
x_test=data.loc[106:149, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
y_test=temp[106:150]
#placeholders and variables. input has 4 features and output has 3 classes
x=tf.placeholder(tf.float32,shape=[None, 4])
y_=tf.placeholder(tf.float32,shape=[None, 3])
#weight and bias
W=tf.Variable(tf.zeros([4,3]))
b=tf.Variable(tf.zeros([3]))
# X is placeholdre for iris features. We will feed data later on
X = tf.placeholder(tf.float32, [None, 4])
# y is placeholder for iris labels. We will feed data later on
Y = tf.placeholder(tf.float32, [3, None])
w = tf.Variable(tf.zeros([4,3]))
b = tf.Variable(tf.zeros([3]))
# model
#softmax function for multiclass classification
y = tf.nn.softmax(tf.matmul(x, W) + b)
#loss function
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
#optimiser -
train_step = tf.train.AdamOptimizer(0.01).minimize(cross_entropy)
#calculating accuracy of our model
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
#session parameters
sess = tf.InteractiveSession()
#initialising variables
init = tf.initialize_all_variables()
sess.run(init)
#number of interations
epochs=2000
for step in range(epochs):
_, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix()) #error line
if step%500==0:
print(c)
Error stack looks like this
ValueError Traceback (most recent call last)
<ipython-input-13-aa781a046f65> in <module>
1 for step in range(epochs):
----> 2 _, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix())
3 if step%500==0:
4 print(c)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in run(self, fetches, feed_dict, options, run_metadata)
893 try:
894 result = self._run(None, fetches, feed_dict, options_ptr,
--> 895 run_metadata_ptr)
896 if run_metadata:
897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1102 'Cannot feed value of shape %r for Tensor %r, '
1103 'which has shape %r'
-> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1105 if not self.graph.is_feedable(subfeed_t):
1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'
python tensorflow logistic-regression
I am trying to perform logistic regression on the iris dataset that I got from here, i am using tensorflow and i feel it is giving me the error in the feed_dict part of the error line.
I tried changing the shape of the the x_input and y_input according to the error that occurred using np.reshape() but it didn't help.
#training data
x_input=data.loc[0:105, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
temp=data['FLOWER']
y_input=temp[0:106]
#test data
x_test=data.loc[106:149, ['SEPAL LENGTH','SEPAL WIDTH','PETAL LENGTH','PETAL WIDTH']]
y_test=temp[106:150]
#placeholders and variables. input has 4 features and output has 3 classes
x=tf.placeholder(tf.float32,shape=[None, 4])
y_=tf.placeholder(tf.float32,shape=[None, 3])
#weight and bias
W=tf.Variable(tf.zeros([4,3]))
b=tf.Variable(tf.zeros([3]))
# X is placeholdre for iris features. We will feed data later on
X = tf.placeholder(tf.float32, [None, 4])
# y is placeholder for iris labels. We will feed data later on
Y = tf.placeholder(tf.float32, [3, None])
w = tf.Variable(tf.zeros([4,3]))
b = tf.Variable(tf.zeros([3]))
# model
#softmax function for multiclass classification
y = tf.nn.softmax(tf.matmul(x, W) + b)
#loss function
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
#optimiser -
train_step = tf.train.AdamOptimizer(0.01).minimize(cross_entropy)
#calculating accuracy of our model
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
#session parameters
sess = tf.InteractiveSession()
#initialising variables
init = tf.initialize_all_variables()
sess.run(init)
#number of interations
epochs=2000
for step in range(epochs):
_, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix()) #error line
if step%500==0:
print(c)
Error stack looks like this
ValueError Traceback (most recent call last)
<ipython-input-13-aa781a046f65> in <module>
1 for step in range(epochs):
----> 2 _, c=sess.run([train_step,cross_entropy], feed_dict=x: x_input.as_matrix(), y_:y_input.as_matrix())
3 if step%500==0:
4 print(c)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in run(self, fetches, feed_dict, options, run_metadata)
893 try:
894 result = self._run(None, fetches, feed_dict, options_ptr,
--> 895 run_metadata_ptr)
896 if run_metadata:
897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
c:usershpanaconda3envsmaskrcnnlibsite-packagestensorflowpythonclientsession.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1102 'Cannot feed value of shape %r for Tensor %r, '
1103 'which has shape %r'
-> 1104 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
1105 if not self.graph.is_feedable(subfeed_t):
1106 raise ValueError('Tensor %s may not be fed.' % subfeed_t)
ValueError: Cannot feed value of shape (106,) for Tensor 'Placeholder_1:0', which has shape '(?, 3)'
python tensorflow logistic-regression
python tensorflow logistic-regression
asked Mar 7 at 7:36
Prakruti ChandakPrakruti Chandak
14
14
add a comment |
add a comment |
0
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
);
);
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%2f55038397%2ftensorflow-logistic-regression-iris-dataset-csv-cannot-feed-value-of-shape-1%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
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.
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%2f55038397%2ftensorflow-logistic-regression-iris-dataset-csv-cannot-feed-value-of-shape-1%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