No OpKernel was registered to support Op 'HashTableV2' with these attrs. Registered devices: [CPU,GPU],...











up vote
0
down vote

favorite












I am coding with tensorflow 1.5.0, python 3.5. I want to create a hashtable. Since I intend to assign values to it later, I create it in the init function like this.(the values and shape are randomly given)
enter image description here



but then I encounter a problem like this
enter image description here



Can anyone help me?










share|improve this question




















  • 1




    Please post your code and error messages as text in the question instead of using screenshots.
    – jdehesa
    Nov 7 at 12:55















up vote
0
down vote

favorite












I am coding with tensorflow 1.5.0, python 3.5. I want to create a hashtable. Since I intend to assign values to it later, I create it in the init function like this.(the values and shape are randomly given)
enter image description here



but then I encounter a problem like this
enter image description here



Can anyone help me?










share|improve this question




















  • 1




    Please post your code and error messages as text in the question instead of using screenshots.
    – jdehesa
    Nov 7 at 12:55













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am coding with tensorflow 1.5.0, python 3.5. I want to create a hashtable. Since I intend to assign values to it later, I create it in the init function like this.(the values and shape are randomly given)
enter image description here



but then I encounter a problem like this
enter image description here



Can anyone help me?










share|improve this question















I am coding with tensorflow 1.5.0, python 3.5. I want to create a hashtable. Since I intend to assign values to it later, I create it in the init function like this.(the values and shape are randomly given)
enter image description here



but then I encounter a problem like this
enter image description here



Can anyone help me?







python tensorflow hashtable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 13:29









jdehesa

21k43150




21k43150










asked Nov 7 at 12:21









jieyu

1




1








  • 1




    Please post your code and error messages as text in the question instead of using screenshots.
    – jdehesa
    Nov 7 at 12:55














  • 1




    Please post your code and error messages as text in the question instead of using screenshots.
    – jdehesa
    Nov 7 at 12:55








1




1




Please post your code and error messages as text in the question instead of using screenshots.
– jdehesa
Nov 7 at 12:55




Please post your code and error messages as text in the question instead of using screenshots.
– jdehesa
Nov 7 at 12:55












2 Answers
2






active

oldest

votes

















up vote
0
down vote













It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. There are two things you can do:





  • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. So one possible fix is to simply change the data type of keys to tf.int64:



    keys = tf.constant([1, 2, 3]), dtype=tf.int64)


  • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. It seems this was added in version v1.11.0-rc0 (see commmit), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem.







share|improve this answer




























    up vote
    0
    down vote













    The answers by @jdehesa is really great. It works for me!!! my tf version is 1.4, python=3.6



    Here is my code which works:



    import tensorflow as tf
    from tensorflow.contrib.lookup import *

    k = tf.range(1, 3, dtype=tf.int64)
    v = tf.range(5, 7, dtype=tf.int64)
    table = tf.contrib.lookup.HashTable(
    tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

    out = table.lookup(tf.constant([2,1], dtype=tf.int64))

    with tf.Session() as sess:
    print(sess.run([k, v]))
    table.init.run()
    print(out.eval())





    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',
      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%2f53189379%2fno-opkernel-was-registered-to-support-op-hashtablev2-with-these-attrs-registe%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








      up vote
      0
      down vote













      It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. There are two things you can do:





      • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. So one possible fix is to simply change the data type of keys to tf.int64:



        keys = tf.constant([1, 2, 3]), dtype=tf.int64)


      • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. It seems this was added in version v1.11.0-rc0 (see commmit), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem.







      share|improve this answer

























        up vote
        0
        down vote













        It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. There are two things you can do:





        • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. So one possible fix is to simply change the data type of keys to tf.int64:



          keys = tf.constant([1, 2, 3]), dtype=tf.int64)


        • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. It seems this was added in version v1.11.0-rc0 (see commmit), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem.







        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. There are two things you can do:





          • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. So one possible fix is to simply change the data type of keys to tf.int64:



            keys = tf.constant([1, 2, 3]), dtype=tf.int64)


          • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. It seems this was added in version v1.11.0-rc0 (see commmit), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem.







          share|improve this answer












          It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. There are two things you can do:





          • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. So one possible fix is to simply change the data type of keys to tf.int64:



            keys = tf.constant([1, 2, 3]), dtype=tf.int64)


          • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. It seems this was added in version v1.11.0-rc0 (see commmit), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 13:04









          jdehesa

          21k43150




          21k43150
























              up vote
              0
              down vote













              The answers by @jdehesa is really great. It works for me!!! my tf version is 1.4, python=3.6



              Here is my code which works:



              import tensorflow as tf
              from tensorflow.contrib.lookup import *

              k = tf.range(1, 3, dtype=tf.int64)
              v = tf.range(5, 7, dtype=tf.int64)
              table = tf.contrib.lookup.HashTable(
              tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

              out = table.lookup(tf.constant([2,1], dtype=tf.int64))

              with tf.Session() as sess:
              print(sess.run([k, v]))
              table.init.run()
              print(out.eval())





              share|improve this answer

























                up vote
                0
                down vote













                The answers by @jdehesa is really great. It works for me!!! my tf version is 1.4, python=3.6



                Here is my code which works:



                import tensorflow as tf
                from tensorflow.contrib.lookup import *

                k = tf.range(1, 3, dtype=tf.int64)
                v = tf.range(5, 7, dtype=tf.int64)
                table = tf.contrib.lookup.HashTable(
                tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

                out = table.lookup(tf.constant([2,1], dtype=tf.int64))

                with tf.Session() as sess:
                print(sess.run([k, v]))
                table.init.run()
                print(out.eval())





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The answers by @jdehesa is really great. It works for me!!! my tf version is 1.4, python=3.6



                  Here is my code which works:



                  import tensorflow as tf
                  from tensorflow.contrib.lookup import *

                  k = tf.range(1, 3, dtype=tf.int64)
                  v = tf.range(5, 7, dtype=tf.int64)
                  table = tf.contrib.lookup.HashTable(
                  tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

                  out = table.lookup(tf.constant([2,1], dtype=tf.int64))

                  with tf.Session() as sess:
                  print(sess.run([k, v]))
                  table.init.run()
                  print(out.eval())





                  share|improve this answer












                  The answers by @jdehesa is really great. It works for me!!! my tf version is 1.4, python=3.6



                  Here is my code which works:



                  import tensorflow as tf
                  from tensorflow.contrib.lookup import *

                  k = tf.range(1, 3, dtype=tf.int64)
                  v = tf.range(5, 7, dtype=tf.int64)
                  table = tf.contrib.lookup.HashTable(
                  tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

                  out = table.lookup(tf.constant([2,1], dtype=tf.int64))

                  with tf.Session() as sess:
                  print(sess.run([k, v]))
                  table.init.run()
                  print(out.eval())






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 12:41









                  huosan0123

                  114




                  114






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189379%2fno-opkernel-was-registered-to-support-op-hashtablev2-with-these-attrs-registe%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







                      這個網誌中的熱門文章

                      Hercules Kyvelos

                      Tangent Lines Diagram Along Smooth Curve

                      Yusuf al-Mu'taman ibn Hud