Keras CNN Error: expected Sequence to have 3 dimensions, but got array with shape (500, 400)












1















I'm getting this error. I'm quite new to ML.




ValueError: Error when checking input: expected Sequence to have 3 dimensions, but got array with shape (500, 400)




These are the below codes that I'm using.



print(X1_Train.shape)
print(X2_Train.shape)
print(y_train.shape)

====================================
Output (here I've 500 rows in each):
(500, 400)
(500, 1500)
(500,)

400 => timesteps (below)
1500 => n (below)
====================================


timesteps = 50 * 8
n = 50 * 30

def createClassifier():
sequence = Input(shape=(timesteps, 1), name='Sequence')
features = Input(shape=(n,), name='Features')

conv = Sequential()
conv.add(Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
conv.add(Conv1D(10, 5, activation='relu'))
conv.add(MaxPool1D(2))
conv.add(Dropout(0.5))

conv.add(Conv1D(5, 6, activation='relu'))
conv.add(Conv1D(5, 6, activation='relu'))
conv.add(MaxPool1D(2))
conv.add(Dropout(0.5))
conv.add(Flatten())
part1 = conv(sequence)

merged = concatenate([part1, features])

final = Dense(512, activation='relu')(merged)
final = Dropout(0.5)(final)
final = Dense(num_class, activation='softmax')(final)

model = Model(inputs=[sequence, features], outputs=[final])
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
return model

model = createClassifier()
# print(model.summary())
history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


Any insight please ?
Thanks in advance.










share|improve this question



























    1















    I'm getting this error. I'm quite new to ML.




    ValueError: Error when checking input: expected Sequence to have 3 dimensions, but got array with shape (500, 400)




    These are the below codes that I'm using.



    print(X1_Train.shape)
    print(X2_Train.shape)
    print(y_train.shape)

    ====================================
    Output (here I've 500 rows in each):
    (500, 400)
    (500, 1500)
    (500,)

    400 => timesteps (below)
    1500 => n (below)
    ====================================


    timesteps = 50 * 8
    n = 50 * 30

    def createClassifier():
    sequence = Input(shape=(timesteps, 1), name='Sequence')
    features = Input(shape=(n,), name='Features')

    conv = Sequential()
    conv.add(Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
    conv.add(Conv1D(10, 5, activation='relu'))
    conv.add(MaxPool1D(2))
    conv.add(Dropout(0.5))

    conv.add(Conv1D(5, 6, activation='relu'))
    conv.add(Conv1D(5, 6, activation='relu'))
    conv.add(MaxPool1D(2))
    conv.add(Dropout(0.5))
    conv.add(Flatten())
    part1 = conv(sequence)

    merged = concatenate([part1, features])

    final = Dense(512, activation='relu')(merged)
    final = Dropout(0.5)(final)
    final = Dense(num_class, activation='softmax')(final)

    model = Model(inputs=[sequence, features], outputs=[final])
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
    return model

    model = createClassifier()
    # print(model.summary())
    history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


    Any insight please ?
    Thanks in advance.










    share|improve this question

























      1












      1








      1








      I'm getting this error. I'm quite new to ML.




      ValueError: Error when checking input: expected Sequence to have 3 dimensions, but got array with shape (500, 400)




      These are the below codes that I'm using.



      print(X1_Train.shape)
      print(X2_Train.shape)
      print(y_train.shape)

      ====================================
      Output (here I've 500 rows in each):
      (500, 400)
      (500, 1500)
      (500,)

      400 => timesteps (below)
      1500 => n (below)
      ====================================


      timesteps = 50 * 8
      n = 50 * 30

      def createClassifier():
      sequence = Input(shape=(timesteps, 1), name='Sequence')
      features = Input(shape=(n,), name='Features')

      conv = Sequential()
      conv.add(Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
      conv.add(Conv1D(10, 5, activation='relu'))
      conv.add(MaxPool1D(2))
      conv.add(Dropout(0.5))

      conv.add(Conv1D(5, 6, activation='relu'))
      conv.add(Conv1D(5, 6, activation='relu'))
      conv.add(MaxPool1D(2))
      conv.add(Dropout(0.5))
      conv.add(Flatten())
      part1 = conv(sequence)

      merged = concatenate([part1, features])

      final = Dense(512, activation='relu')(merged)
      final = Dropout(0.5)(final)
      final = Dense(num_class, activation='softmax')(final)

      model = Model(inputs=[sequence, features], outputs=[final])
      model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
      return model

      model = createClassifier()
      # print(model.summary())
      history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


      Any insight please ?
      Thanks in advance.










      share|improve this question














      I'm getting this error. I'm quite new to ML.




      ValueError: Error when checking input: expected Sequence to have 3 dimensions, but got array with shape (500, 400)




      These are the below codes that I'm using.



      print(X1_Train.shape)
      print(X2_Train.shape)
      print(y_train.shape)

      ====================================
      Output (here I've 500 rows in each):
      (500, 400)
      (500, 1500)
      (500,)

      400 => timesteps (below)
      1500 => n (below)
      ====================================


      timesteps = 50 * 8
      n = 50 * 30

      def createClassifier():
      sequence = Input(shape=(timesteps, 1), name='Sequence')
      features = Input(shape=(n,), name='Features')

      conv = Sequential()
      conv.add(Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
      conv.add(Conv1D(10, 5, activation='relu'))
      conv.add(MaxPool1D(2))
      conv.add(Dropout(0.5))

      conv.add(Conv1D(5, 6, activation='relu'))
      conv.add(Conv1D(5, 6, activation='relu'))
      conv.add(MaxPool1D(2))
      conv.add(Dropout(0.5))
      conv.add(Flatten())
      part1 = conv(sequence)

      merged = concatenate([part1, features])

      final = Dense(512, activation='relu')(merged)
      final = Dropout(0.5)(final)
      final = Dense(num_class, activation='softmax')(final)

      model = Model(inputs=[sequence, features], outputs=[final])
      model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
      return model

      model = createClassifier()
      # print(model.summary())
      history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


      Any insight please ?
      Thanks in advance.







      python machine-learning keras conv-neural-network






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 6:03









      Temp ExptTemp Expt

      244




      244
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Two things -



          Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

          You need to reshape your input layer, add another axis, of size 1. (this does not change anything in your data).



          You are trying to use multiple inputs, Sequential API is not the best choice for that. I would recommend using the Functional API



          Edit:
          Regarding your comment, not sure what you did wrong, but this is a working version of your code (with fake data), with a reshape:



          import keras

          import numpy as np



          X1_Train = np.ones((500,400))
          X2_Train = np.ones((500,1500))
          y_train = np.ones((500))
          print(X1_Train.shape)
          print(X2_Train.shape)
          print(y_train.shape)

          num_class = 1


          timesteps = 50 * 8
          n = 50 * 30

          def createClassifier():
          sequence = keras.layers.Input(shape=(timesteps, 1), name='Sequence')
          features = keras.layers.Input(shape=(n,), name='Features')

          conv = keras.Sequential()
          conv.add(keras.layers.Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
          conv.add(keras.layers.Conv1D(10, 5, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))

          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))
          conv.add(keras.layers.Flatten())
          part1 = conv(sequence)

          merged = keras.layers.concatenate([part1, features])

          final = keras.layers.Dense(512, activation='relu')(merged)
          final = keras.layers.Dropout(0.5)(final)
          final = keras.layers.Dense(num_class, activation='softmax')(final)

          model = keras.Model(inputs=[sequence, features], outputs=[final])
          model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
          return model

          model = createClassifier()
          # print(model.summary())
          X1_Train = X1_Train.reshape((500,400,1))
          history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


          With output:



          Using TensorFlow backend.
          (500, 400)
          (500, 1500)
          (500,)
          Epoch 1/5
          500/500 [==============================] - 1s 3ms/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 2/5
          500/500 [==============================] - 0s 160us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 3/5
          500/500 [==============================] - 0s 166us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 4/5
          500/500 [==============================] - 0s 154us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 5/5
          500/500 [==============================] - 0s 157us/step - loss: 1.1921e-07 - acc: 1.0000





          share|improve this answer


























          • changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

            – Temp Expt
            Nov 25 '18 at 9:10













          • Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

            – Dinari
            Nov 25 '18 at 9:24











          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%2f53465066%2fkeras-cnn-error-expected-sequence-to-have-3-dimensions-but-got-array-with-shap%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









          1














          Two things -



          Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

          You need to reshape your input layer, add another axis, of size 1. (this does not change anything in your data).



          You are trying to use multiple inputs, Sequential API is not the best choice for that. I would recommend using the Functional API



          Edit:
          Regarding your comment, not sure what you did wrong, but this is a working version of your code (with fake data), with a reshape:



          import keras

          import numpy as np



          X1_Train = np.ones((500,400))
          X2_Train = np.ones((500,1500))
          y_train = np.ones((500))
          print(X1_Train.shape)
          print(X2_Train.shape)
          print(y_train.shape)

          num_class = 1


          timesteps = 50 * 8
          n = 50 * 30

          def createClassifier():
          sequence = keras.layers.Input(shape=(timesteps, 1), name='Sequence')
          features = keras.layers.Input(shape=(n,), name='Features')

          conv = keras.Sequential()
          conv.add(keras.layers.Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
          conv.add(keras.layers.Conv1D(10, 5, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))

          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))
          conv.add(keras.layers.Flatten())
          part1 = conv(sequence)

          merged = keras.layers.concatenate([part1, features])

          final = keras.layers.Dense(512, activation='relu')(merged)
          final = keras.layers.Dropout(0.5)(final)
          final = keras.layers.Dense(num_class, activation='softmax')(final)

          model = keras.Model(inputs=[sequence, features], outputs=[final])
          model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
          return model

          model = createClassifier()
          # print(model.summary())
          X1_Train = X1_Train.reshape((500,400,1))
          history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


          With output:



          Using TensorFlow backend.
          (500, 400)
          (500, 1500)
          (500,)
          Epoch 1/5
          500/500 [==============================] - 1s 3ms/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 2/5
          500/500 [==============================] - 0s 160us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 3/5
          500/500 [==============================] - 0s 166us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 4/5
          500/500 [==============================] - 0s 154us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 5/5
          500/500 [==============================] - 0s 157us/step - loss: 1.1921e-07 - acc: 1.0000





          share|improve this answer


























          • changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

            – Temp Expt
            Nov 25 '18 at 9:10













          • Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

            – Dinari
            Nov 25 '18 at 9:24
















          1














          Two things -



          Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

          You need to reshape your input layer, add another axis, of size 1. (this does not change anything in your data).



          You are trying to use multiple inputs, Sequential API is not the best choice for that. I would recommend using the Functional API



          Edit:
          Regarding your comment, not sure what you did wrong, but this is a working version of your code (with fake data), with a reshape:



          import keras

          import numpy as np



          X1_Train = np.ones((500,400))
          X2_Train = np.ones((500,1500))
          y_train = np.ones((500))
          print(X1_Train.shape)
          print(X2_Train.shape)
          print(y_train.shape)

          num_class = 1


          timesteps = 50 * 8
          n = 50 * 30

          def createClassifier():
          sequence = keras.layers.Input(shape=(timesteps, 1), name='Sequence')
          features = keras.layers.Input(shape=(n,), name='Features')

          conv = keras.Sequential()
          conv.add(keras.layers.Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
          conv.add(keras.layers.Conv1D(10, 5, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))

          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))
          conv.add(keras.layers.Flatten())
          part1 = conv(sequence)

          merged = keras.layers.concatenate([part1, features])

          final = keras.layers.Dense(512, activation='relu')(merged)
          final = keras.layers.Dropout(0.5)(final)
          final = keras.layers.Dense(num_class, activation='softmax')(final)

          model = keras.Model(inputs=[sequence, features], outputs=[final])
          model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
          return model

          model = createClassifier()
          # print(model.summary())
          X1_Train = X1_Train.reshape((500,400,1))
          history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


          With output:



          Using TensorFlow backend.
          (500, 400)
          (500, 1500)
          (500,)
          Epoch 1/5
          500/500 [==============================] - 1s 3ms/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 2/5
          500/500 [==============================] - 0s 160us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 3/5
          500/500 [==============================] - 0s 166us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 4/5
          500/500 [==============================] - 0s 154us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 5/5
          500/500 [==============================] - 0s 157us/step - loss: 1.1921e-07 - acc: 1.0000





          share|improve this answer


























          • changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

            – Temp Expt
            Nov 25 '18 at 9:10













          • Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

            – Dinari
            Nov 25 '18 at 9:24














          1












          1








          1







          Two things -



          Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

          You need to reshape your input layer, add another axis, of size 1. (this does not change anything in your data).



          You are trying to use multiple inputs, Sequential API is not the best choice for that. I would recommend using the Functional API



          Edit:
          Regarding your comment, not sure what you did wrong, but this is a working version of your code (with fake data), with a reshape:



          import keras

          import numpy as np



          X1_Train = np.ones((500,400))
          X2_Train = np.ones((500,1500))
          y_train = np.ones((500))
          print(X1_Train.shape)
          print(X2_Train.shape)
          print(y_train.shape)

          num_class = 1


          timesteps = 50 * 8
          n = 50 * 30

          def createClassifier():
          sequence = keras.layers.Input(shape=(timesteps, 1), name='Sequence')
          features = keras.layers.Input(shape=(n,), name='Features')

          conv = keras.Sequential()
          conv.add(keras.layers.Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
          conv.add(keras.layers.Conv1D(10, 5, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))

          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))
          conv.add(keras.layers.Flatten())
          part1 = conv(sequence)

          merged = keras.layers.concatenate([part1, features])

          final = keras.layers.Dense(512, activation='relu')(merged)
          final = keras.layers.Dropout(0.5)(final)
          final = keras.layers.Dense(num_class, activation='softmax')(final)

          model = keras.Model(inputs=[sequence, features], outputs=[final])
          model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
          return model

          model = createClassifier()
          # print(model.summary())
          X1_Train = X1_Train.reshape((500,400,1))
          history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


          With output:



          Using TensorFlow backend.
          (500, 400)
          (500, 1500)
          (500,)
          Epoch 1/5
          500/500 [==============================] - 1s 3ms/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 2/5
          500/500 [==============================] - 0s 160us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 3/5
          500/500 [==============================] - 0s 166us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 4/5
          500/500 [==============================] - 0s 154us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 5/5
          500/500 [==============================] - 0s 157us/step - loss: 1.1921e-07 - acc: 1.0000





          share|improve this answer















          Two things -



          Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

          You need to reshape your input layer, add another axis, of size 1. (this does not change anything in your data).



          You are trying to use multiple inputs, Sequential API is not the best choice for that. I would recommend using the Functional API



          Edit:
          Regarding your comment, not sure what you did wrong, but this is a working version of your code (with fake data), with a reshape:



          import keras

          import numpy as np



          X1_Train = np.ones((500,400))
          X2_Train = np.ones((500,1500))
          y_train = np.ones((500))
          print(X1_Train.shape)
          print(X2_Train.shape)
          print(y_train.shape)

          num_class = 1


          timesteps = 50 * 8
          n = 50 * 30

          def createClassifier():
          sequence = keras.layers.Input(shape=(timesteps, 1), name='Sequence')
          features = keras.layers.Input(shape=(n,), name='Features')

          conv = keras.Sequential()
          conv.add(keras.layers.Conv1D(10, 5, activation='relu', input_shape=(timesteps, 1)))
          conv.add(keras.layers.Conv1D(10, 5, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))

          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.Conv1D(5, 6, activation='relu'))
          conv.add(keras.layers.MaxPool1D(2))
          conv.add(keras.layers.Dropout(0.5))
          conv.add(keras.layers.Flatten())
          part1 = conv(sequence)

          merged = keras.layers.concatenate([part1, features])

          final = keras.layers.Dense(512, activation='relu')(merged)
          final = keras.layers.Dropout(0.5)(final)
          final = keras.layers.Dense(num_class, activation='softmax')(final)

          model = keras.Model(inputs=[sequence, features], outputs=[final])
          model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
          return model

          model = createClassifier()
          # print(model.summary())
          X1_Train = X1_Train.reshape((500,400,1))
          history = model.fit([X1_Train, X2_Train], y_train, epochs =5)


          With output:



          Using TensorFlow backend.
          (500, 400)
          (500, 1500)
          (500,)
          Epoch 1/5
          500/500 [==============================] - 1s 3ms/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 2/5
          500/500 [==============================] - 0s 160us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 3/5
          500/500 [==============================] - 0s 166us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 4/5
          500/500 [==============================] - 0s 154us/step - loss: 1.1921e-07 - acc: 1.0000
          Epoch 5/5
          500/500 [==============================] - 0s 157us/step - loss: 1.1921e-07 - acc: 1.0000






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 25 '18 at 9:22

























          answered Nov 25 '18 at 7:27









          DinariDinari

          1,669522




          1,669522













          • changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

            – Temp Expt
            Nov 25 '18 at 9:10













          • Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

            – Dinari
            Nov 25 '18 at 9:24



















          • changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

            – Temp Expt
            Nov 25 '18 at 9:10













          • Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

            – Dinari
            Nov 25 '18 at 9:24

















          changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

          – Temp Expt
          Nov 25 '18 at 9:10







          changed accordingly to (500, 400, 1). But it didn't work. I'm still getting an error. I changed the CNN layer as per functional API. But, I'm getting the below error. tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[22,330] = -1 is not in [0, 400)

          – Temp Expt
          Nov 25 '18 at 9:10















          Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

          – Dinari
          Nov 25 '18 at 9:24





          Not sure what you did wrong with the reshape, edited and added a working version of your code, with fake data, note that I only added the reshape line.

          – Dinari
          Nov 25 '18 at 9:24




















          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%2f53465066%2fkeras-cnn-error-expected-sequence-to-have-3-dimensions-but-got-array-with-shap%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

          To store a contact into the json file from server.js file using a class in NodeJS

          Redirect URL with Chrome Remote Debugging Android Devices

          Dieringhausen