Keras: IndexError: tuple index out of range - Conv2D












0














I'm new in Keras and Tensorflow. I'm trying to run some specific code based on Keras and Tensorflow. In that code, I prepared dataset from tfrecordes files and reshape it with tf.reshape(image, [32, 32, 3]), in my model, I need to apply a Conv2D layer on this image output, I using Keras, in my code below:



# Image
x = k.layers.Input(shape=input_shape,tensor=img)
# ReLU Conv1
conv1 = k.layers.Conv2D(filters = 256, kernel_size = 9, strides=1,padding='valid', activation='relu', name='conv1')(x)


the problem is that, when I run the code, I got this error:




self.kernel_size[i],
IndexError: tuple index out of range




so, after many searches, I found that this error may be fixed by change Keras ver from 2.2 to 1.2.
I do that but actually, I must change all of my code, do anybody how can fix this error just in Keras 2.2, without using Karas 1.2?










share|improve this question



























    0














    I'm new in Keras and Tensorflow. I'm trying to run some specific code based on Keras and Tensorflow. In that code, I prepared dataset from tfrecordes files and reshape it with tf.reshape(image, [32, 32, 3]), in my model, I need to apply a Conv2D layer on this image output, I using Keras, in my code below:



    # Image
    x = k.layers.Input(shape=input_shape,tensor=img)
    # ReLU Conv1
    conv1 = k.layers.Conv2D(filters = 256, kernel_size = 9, strides=1,padding='valid', activation='relu', name='conv1')(x)


    the problem is that, when I run the code, I got this error:




    self.kernel_size[i],
    IndexError: tuple index out of range




    so, after many searches, I found that this error may be fixed by change Keras ver from 2.2 to 1.2.
    I do that but actually, I must change all of my code, do anybody how can fix this error just in Keras 2.2, without using Karas 1.2?










    share|improve this question

























      0












      0








      0







      I'm new in Keras and Tensorflow. I'm trying to run some specific code based on Keras and Tensorflow. In that code, I prepared dataset from tfrecordes files and reshape it with tf.reshape(image, [32, 32, 3]), in my model, I need to apply a Conv2D layer on this image output, I using Keras, in my code below:



      # Image
      x = k.layers.Input(shape=input_shape,tensor=img)
      # ReLU Conv1
      conv1 = k.layers.Conv2D(filters = 256, kernel_size = 9, strides=1,padding='valid', activation='relu', name='conv1')(x)


      the problem is that, when I run the code, I got this error:




      self.kernel_size[i],
      IndexError: tuple index out of range




      so, after many searches, I found that this error may be fixed by change Keras ver from 2.2 to 1.2.
      I do that but actually, I must change all of my code, do anybody how can fix this error just in Keras 2.2, without using Karas 1.2?










      share|improve this question













      I'm new in Keras and Tensorflow. I'm trying to run some specific code based on Keras and Tensorflow. In that code, I prepared dataset from tfrecordes files and reshape it with tf.reshape(image, [32, 32, 3]), in my model, I need to apply a Conv2D layer on this image output, I using Keras, in my code below:



      # Image
      x = k.layers.Input(shape=input_shape,tensor=img)
      # ReLU Conv1
      conv1 = k.layers.Conv2D(filters = 256, kernel_size = 9, strides=1,padding='valid', activation='relu', name='conv1')(x)


      the problem is that, when I run the code, I got this error:




      self.kernel_size[i],
      IndexError: tuple index out of range




      so, after many searches, I found that this error may be fixed by change Keras ver from 2.2 to 1.2.
      I do that but actually, I must change all of my code, do anybody how can fix this error just in Keras 2.2, without using Karas 1.2?







      python tensorflow keras






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 10:53









      Vahid

      15




      15
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I think you need a 9 * 9 kernel. Change kernel_size=9 to kernel_size=( 9 , 9 )
          Edited code line :



          conv1 = k.layers.Conv2D(filters = 256, kernel_size = ( 9 , 9 ), strides=1,padding='valid', activation='relu', name='conv1')(x)





          share|improve this answer





















          • this change has not any effect!
            – Vahid
            Nov 20 '18 at 12:00











          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%2f53391412%2fkeras-indexerror-tuple-index-out-of-range-conv2d%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I think you need a 9 * 9 kernel. Change kernel_size=9 to kernel_size=( 9 , 9 )
          Edited code line :



          conv1 = k.layers.Conv2D(filters = 256, kernel_size = ( 9 , 9 ), strides=1,padding='valid', activation='relu', name='conv1')(x)





          share|improve this answer





















          • this change has not any effect!
            – Vahid
            Nov 20 '18 at 12:00
















          0














          I think you need a 9 * 9 kernel. Change kernel_size=9 to kernel_size=( 9 , 9 )
          Edited code line :



          conv1 = k.layers.Conv2D(filters = 256, kernel_size = ( 9 , 9 ), strides=1,padding='valid', activation='relu', name='conv1')(x)





          share|improve this answer





















          • this change has not any effect!
            – Vahid
            Nov 20 '18 at 12:00














          0












          0








          0






          I think you need a 9 * 9 kernel. Change kernel_size=9 to kernel_size=( 9 , 9 )
          Edited code line :



          conv1 = k.layers.Conv2D(filters = 256, kernel_size = ( 9 , 9 ), strides=1,padding='valid', activation='relu', name='conv1')(x)





          share|improve this answer












          I think you need a 9 * 9 kernel. Change kernel_size=9 to kernel_size=( 9 , 9 )
          Edited code line :



          conv1 = k.layers.Conv2D(filters = 256, kernel_size = ( 9 , 9 ), strides=1,padding='valid', activation='relu', name='conv1')(x)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 11:06









          Shubham Panchal

          459110




          459110












          • this change has not any effect!
            – Vahid
            Nov 20 '18 at 12:00


















          • this change has not any effect!
            – Vahid
            Nov 20 '18 at 12:00
















          this change has not any effect!
          – Vahid
          Nov 20 '18 at 12:00




          this change has not any effect!
          – Vahid
          Nov 20 '18 at 12:00


















          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%2f53391412%2fkeras-indexerror-tuple-index-out-of-range-conv2d%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?