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;








1















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?










share|improve this question


























  • Have you read your answers ?

    – Mohan Radhakrishnan
    Apr 8 at 10:08

















1















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?










share|improve this question


























  • Have you read your answers ?

    – Mohan Radhakrishnan
    Apr 8 at 10:08













1












1








1








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















2














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.]]





share|improve this answer
































    0














    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.]]





    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%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









      2














      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.]]





      share|improve this answer





























        2














        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.]]





        share|improve this answer



























          2












          2








          2







          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.]]





          share|improve this answer













          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.]]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


























              0














              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.]]





              share|improve this answer





























                0














                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.]]





                share|improve this answer



























                  0












                  0








                  0







                  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.]]





                  share|improve this answer













                  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.]]






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  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






























                      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%2f55370317%2ftensorflow-polynomial-array%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

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현