Tensorflow Polynomial ArrayHow Can I Multiply Two Dynamic Dimension TensorsPlaceholder missing error in Tensor flow for CNNTensorFlow not found using pipTensorflow - You must feed a value for placeholder tensor 'X' with dtype floatSimple Feedforward Neural Network with TensorFlow won't learnCan't run prediciton because of troubles with tf.placeholderTensorflow coreTensorflow seq2seq Decoder problems?Error when calling global_variables_initializer in TensorFlowtflite 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)'
Why don't the open notes matter in guitar chords?
Traveling from Germany to other countries by train?
Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?
Does this smartphone photo show Mars just below the Sun?
Which genus do I use for neutral expressions in German?
Responding to Plague Engineer
Are children a reason to be rejected for a job?
Generate a random point outside a given rectangle within a map
Cobb-Douglas production function with expenditures rather than units
How do these cubesats' whip antennas work?
How do I get the =LEFT function in excel, to also take the number zero as the first number?
The actual purview of Her Majesty The Queen's Perogative?
Colleagues speaking another language and it impacts work
How many years before enough atoms of your body are replaced to survive the sudden disappearance of the original body’s atoms?
Does the length of a password for Wi-Fi affect speed?
What could prevent players from leaving an island?
Is Odin inconsistent about the powers of Mjolnir?
Is a switch from R to Python worth it?
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
Is there a drawback to Flail Snail's Shell defense?
What city skyline is this picture of?
Making pause in a diagram
Pronouns when writing from the point of view of a robot
How to draw a flow chart?
Tensorflow Polynomial Array
How Can I Multiply Two Dynamic Dimension TensorsPlaceholder missing error in Tensor flow for CNNTensorFlow not found using pipTensorflow - You must feed a value for placeholder tensor 'X' with dtype floatSimple Feedforward Neural Network with TensorFlow won't learnCan't run prediciton because of troubles with tf.placeholderTensorflow coreTensorflow seq2seq Decoder problems?Error when calling global_variables_initializer in TensorFlowtflite 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)'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to evaluate aX^2+bX+c
, as [a,b,c]*[X*X X 1]
in tensorflow.
I've tried the following code:
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W=tf.reshape(W,[1,3])
F = tf.Variable([X*X,X,1.0], dtype=tf.float32, name="Filter")
F=tf.reshape(F,[3,1])
print(W.shape)
print(F.shape)
Y=tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
sess.run(Y, feed_dict=X: i)
Y=sess.run(Y)
print("Y:",Y)
However, initializer is not happy:
(1, 3)
(3, 1)
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'X' with dtype float
[[node X]]
During handling of the above exception, another exception occurred:
...
Caused by op 'X', defined at:
File "sample.py", line 2, in <module>
X = tf.placeholder(tf.float32, name="X")
...
Any thoughts, as to possible alternatives?
python tensorflow
add a comment |
I'm trying to evaluate aX^2+bX+c
, as [a,b,c]*[X*X X 1]
in tensorflow.
I've tried the following code:
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W=tf.reshape(W,[1,3])
F = tf.Variable([X*X,X,1.0], dtype=tf.float32, name="Filter")
F=tf.reshape(F,[3,1])
print(W.shape)
print(F.shape)
Y=tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
sess.run(Y, feed_dict=X: i)
Y=sess.run(Y)
print("Y:",Y)
However, initializer is not happy:
(1, 3)
(3, 1)
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'X' with dtype float
[[node X]]
During handling of the above exception, another exception occurred:
...
Caused by op 'X', defined at:
File "sample.py", line 2, in <module>
X = tf.placeholder(tf.float32, name="X")
...
Any thoughts, as to possible alternatives?
python tensorflow
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08
add a comment |
I'm trying to evaluate aX^2+bX+c
, as [a,b,c]*[X*X X 1]
in tensorflow.
I've tried the following code:
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W=tf.reshape(W,[1,3])
F = tf.Variable([X*X,X,1.0], dtype=tf.float32, name="Filter")
F=tf.reshape(F,[3,1])
print(W.shape)
print(F.shape)
Y=tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
sess.run(Y, feed_dict=X: i)
Y=sess.run(Y)
print("Y:",Y)
However, initializer is not happy:
(1, 3)
(3, 1)
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'X' with dtype float
[[node X]]
During handling of the above exception, another exception occurred:
...
Caused by op 'X', defined at:
File "sample.py", line 2, in <module>
X = tf.placeholder(tf.float32, name="X")
...
Any thoughts, as to possible alternatives?
python tensorflow
I'm trying to evaluate aX^2+bX+c
, as [a,b,c]*[X*X X 1]
in tensorflow.
I've tried the following code:
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W=tf.reshape(W,[1,3])
F = tf.Variable([X*X,X,1.0], dtype=tf.float32, name="Filter")
F=tf.reshape(F,[3,1])
print(W.shape)
print(F.shape)
Y=tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
sess.run(Y, feed_dict=X: i)
Y=sess.run(Y)
print("Y:",Y)
However, initializer is not happy:
(1, 3)
(3, 1)
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'X' with dtype float
[[node X]]
During handling of the above exception, another exception occurred:
...
Caused by op 'X', defined at:
File "sample.py", line 2, in <module>
X = tf.placeholder(tf.float32, name="X")
...
Any thoughts, as to possible alternatives?
python tensorflow
python tensorflow
edited Mar 27 at 5:55
Arkistarvh Kltzuonstev
3,5233 gold badges13 silver badges35 bronze badges
3,5233 gold badges13 silver badges35 bronze badges
asked Mar 27 at 5:24
NastoohNastooh
1134 bronze badges
1134 bronze badges
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08
add a comment |
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08
add a comment |
2 Answers
2
active
oldest
votes
You just need to modify the code a little bit. The value of tf.Variable
should not be tf.placeholder
, otherwise it will cause your initialization error when running sess.run(tf.global_variables_initializer())
. You can use tf.stack
instead of it.
In addition, please remember to feed data when you run sess.run(Y)
.
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W = tf.reshape(W,[1,3])
F = tf.stack([X*X,X,1.0])
F = tf.reshape(F,[3,1])
Y = tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
Y_val = sess.run(Y, feed_dict=X: i)
print("Y:",Y_val)
Y: [[1.]]
Y: [[4.]]
Y: [[9.]]
Y: [[16.]]
Y: [[25.]]
Y: [[36.]]
Y: [[49.]]
Y: [[64.]]
Y: [[81.]]
Y: [[100.]]
add a comment |
I think even though you could still initialize a variable that depends on a placeholder like this, W
will get initialized repeatedly unless you add more code to initialize only uninitialized variables. That is more effort.
Hope I haven't missed other inefficiencies in this approach.
import tensorflow as tf
sess = tf.InteractiveSession()
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1, 2, 1], dtype=tf.float32, name="weights")
W = tf.reshape(W, [1, 3])
var = tf.reshape([X*X,X,1],[3,1])
F = tf.get_variable('F', dtype=tf.float32, initializer=var)
init = tf.global_variables_initializer()
Y=tf.matmul(W,F)
for i in range(10):
sess.run([init], feed_dict=X: i)
print(sess.run(Y))
[[1.]]
[[4.]]
[[9.]]
[[16.]]
[[25.]]
[[36.]]
[[49.]]
[[64.]]
[[81.]]
[[100.]]
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%2f55370317%2ftensorflow-polynomial-array%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You just need to modify the code a little bit. The value of tf.Variable
should not be tf.placeholder
, otherwise it will cause your initialization error when running sess.run(tf.global_variables_initializer())
. You can use tf.stack
instead of it.
In addition, please remember to feed data when you run sess.run(Y)
.
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W = tf.reshape(W,[1,3])
F = tf.stack([X*X,X,1.0])
F = tf.reshape(F,[3,1])
Y = tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
Y_val = sess.run(Y, feed_dict=X: i)
print("Y:",Y_val)
Y: [[1.]]
Y: [[4.]]
Y: [[9.]]
Y: [[16.]]
Y: [[25.]]
Y: [[36.]]
Y: [[49.]]
Y: [[64.]]
Y: [[81.]]
Y: [[100.]]
add a comment |
You just need to modify the code a little bit. The value of tf.Variable
should not be tf.placeholder
, otherwise it will cause your initialization error when running sess.run(tf.global_variables_initializer())
. You can use tf.stack
instead of it.
In addition, please remember to feed data when you run sess.run(Y)
.
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W = tf.reshape(W,[1,3])
F = tf.stack([X*X,X,1.0])
F = tf.reshape(F,[3,1])
Y = tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
Y_val = sess.run(Y, feed_dict=X: i)
print("Y:",Y_val)
Y: [[1.]]
Y: [[4.]]
Y: [[9.]]
Y: [[16.]]
Y: [[25.]]
Y: [[36.]]
Y: [[49.]]
Y: [[64.]]
Y: [[81.]]
Y: [[100.]]
add a comment |
You just need to modify the code a little bit. The value of tf.Variable
should not be tf.placeholder
, otherwise it will cause your initialization error when running sess.run(tf.global_variables_initializer())
. You can use tf.stack
instead of it.
In addition, please remember to feed data when you run sess.run(Y)
.
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W = tf.reshape(W,[1,3])
F = tf.stack([X*X,X,1.0])
F = tf.reshape(F,[3,1])
Y = tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
Y_val = sess.run(Y, feed_dict=X: i)
print("Y:",Y_val)
Y: [[1.]]
Y: [[4.]]
Y: [[9.]]
Y: [[16.]]
Y: [[25.]]
Y: [[36.]]
Y: [[49.]]
Y: [[64.]]
Y: [[81.]]
Y: [[100.]]
You just need to modify the code a little bit. The value of tf.Variable
should not be tf.placeholder
, otherwise it will cause your initialization error when running sess.run(tf.global_variables_initializer())
. You can use tf.stack
instead of it.
In addition, please remember to feed data when you run sess.run(Y)
.
import tensorflow as tf
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1,2,1], dtype=tf.float32, name="weights")
W = tf.reshape(W,[1,3])
F = tf.stack([X*X,X,1.0])
F = tf.reshape(F,[3,1])
Y = tf.matmul(W,F)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(10):
Y_val = sess.run(Y, feed_dict=X: i)
print("Y:",Y_val)
Y: [[1.]]
Y: [[4.]]
Y: [[9.]]
Y: [[16.]]
Y: [[25.]]
Y: [[36.]]
Y: [[49.]]
Y: [[64.]]
Y: [[81.]]
Y: [[100.]]
answered Mar 27 at 7:56
giser_yuganggiser_yugang
4,2972 gold badges9 silver badges31 bronze badges
4,2972 gold badges9 silver badges31 bronze badges
add a comment |
add a comment |
I think even though you could still initialize a variable that depends on a placeholder like this, W
will get initialized repeatedly unless you add more code to initialize only uninitialized variables. That is more effort.
Hope I haven't missed other inefficiencies in this approach.
import tensorflow as tf
sess = tf.InteractiveSession()
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1, 2, 1], dtype=tf.float32, name="weights")
W = tf.reshape(W, [1, 3])
var = tf.reshape([X*X,X,1],[3,1])
F = tf.get_variable('F', dtype=tf.float32, initializer=var)
init = tf.global_variables_initializer()
Y=tf.matmul(W,F)
for i in range(10):
sess.run([init], feed_dict=X: i)
print(sess.run(Y))
[[1.]]
[[4.]]
[[9.]]
[[16.]]
[[25.]]
[[36.]]
[[49.]]
[[64.]]
[[81.]]
[[100.]]
add a comment |
I think even though you could still initialize a variable that depends on a placeholder like this, W
will get initialized repeatedly unless you add more code to initialize only uninitialized variables. That is more effort.
Hope I haven't missed other inefficiencies in this approach.
import tensorflow as tf
sess = tf.InteractiveSession()
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1, 2, 1], dtype=tf.float32, name="weights")
W = tf.reshape(W, [1, 3])
var = tf.reshape([X*X,X,1],[3,1])
F = tf.get_variable('F', dtype=tf.float32, initializer=var)
init = tf.global_variables_initializer()
Y=tf.matmul(W,F)
for i in range(10):
sess.run([init], feed_dict=X: i)
print(sess.run(Y))
[[1.]]
[[4.]]
[[9.]]
[[16.]]
[[25.]]
[[36.]]
[[49.]]
[[64.]]
[[81.]]
[[100.]]
add a comment |
I think even though you could still initialize a variable that depends on a placeholder like this, W
will get initialized repeatedly unless you add more code to initialize only uninitialized variables. That is more effort.
Hope I haven't missed other inefficiencies in this approach.
import tensorflow as tf
sess = tf.InteractiveSession()
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1, 2, 1], dtype=tf.float32, name="weights")
W = tf.reshape(W, [1, 3])
var = tf.reshape([X*X,X,1],[3,1])
F = tf.get_variable('F', dtype=tf.float32, initializer=var)
init = tf.global_variables_initializer()
Y=tf.matmul(W,F)
for i in range(10):
sess.run([init], feed_dict=X: i)
print(sess.run(Y))
[[1.]]
[[4.]]
[[9.]]
[[16.]]
[[25.]]
[[36.]]
[[49.]]
[[64.]]
[[81.]]
[[100.]]
I think even though you could still initialize a variable that depends on a placeholder like this, W
will get initialized repeatedly unless you add more code to initialize only uninitialized variables. That is more effort.
Hope I haven't missed other inefficiencies in this approach.
import tensorflow as tf
sess = tf.InteractiveSession()
X = tf.placeholder(tf.float32, name="X")
W = tf.Variable([1, 2, 1], dtype=tf.float32, name="weights")
W = tf.reshape(W, [1, 3])
var = tf.reshape([X*X,X,1],[3,1])
F = tf.get_variable('F', dtype=tf.float32, initializer=var)
init = tf.global_variables_initializer()
Y=tf.matmul(W,F)
for i in range(10):
sess.run([init], feed_dict=X: i)
print(sess.run(Y))
[[1.]]
[[4.]]
[[9.]]
[[16.]]
[[25.]]
[[36.]]
[[49.]]
[[64.]]
[[81.]]
[[100.]]
answered Mar 28 at 8:09
Mohan RadhakrishnanMohan Radhakrishnan
1,5944 gold badges13 silver badges29 bronze badges
1,5944 gold badges13 silver badges29 bronze badges
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%2f55370317%2ftensorflow-polynomial-array%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
Have you read your answers ?
– Mohan Radhakrishnan
Apr 8 at 10:08