title: ValueError: Exception encountered when calling layer "sequential" when I try to call the predict
body: <p>I am writing a neural network for hand gesture recognition based on hand landmark coordinates. But when I try to send data to a trained neural network, I get this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\belog\drone_sees2\drone_vision.py&quot;, line 64, in &lt;module&gt;
      pred = model.predict(new_row)
    File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\utils\traceback_utils.py&quot;, line 67, in error_handler
      raise e.with_traceback(filtered_tb) from None
    File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\tensorflow\python\framework\func_graph.py&quot;, line 1147, in autograph_handler
      raise e.ag_error_metadata.to_exception(e)
  ValueError: in user code:
  
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\engine\training.py&quot;, line 1801, in predict_function  *
          return step_function(self, iterator)
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\engine\training.py&quot;, line 1790, in step_function  **
          outputs = model.distribute_strategy.run(run_step, args=(data,))
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\engine\training.py&quot;, line 1783, in run_step  **
          outputs = model.predict_step(data)
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\engine\training.py&quot;, line 1751, in predict_step
          return self(x, training=False)
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\utils\traceback_utils.py&quot;, line 67, in error_handler
          raise e.with_traceback(filtered_tb) from None
      File &quot;C:\Users\belog\drone_sees2\venv\lib\site-packages\keras\engine\input_spec.py&quot;, line 228, in assert_input_compatibility
          raise ValueError(f'Input {input_index} of layer &quot;{layer_name}&quot; '
  
      ValueError: Exception encountered when calling layer &quot;sequential&quot; (type Sequential).
      
      Input 0 of layer &quot;dense&quot; is incompatible with the layer: expected min_ndim=2, found ndim=1. Full shape received: (None,)
      
      Call arguments received:
        • inputs=tf.Tensor(shape=(None,), dtype=int32)
        • training=False
        • mask=None
  </code></pre>
  <p>Here is my code for training the neural network model:</p>
  <pre><code>model = keras.models.Sequential([Input(shape=(43,)),
                                  Dense(units=128, activation='relu'),
                                  Dense(units=6, activation='softmax')])
  
  model.compile(optimizer='adam',
               loss='categorical_crossentropy',
               metrics=['accuracy'])
  
  model.fit(x_train, y_train_cat, batch_size=32, epochs=5, validation_split=0.2)
  
  model.save(&quot;gestures_model.h5&quot;)
  </code></pre>
  <p>Here is my code for recognition gestuares:</p>
  <pre><code>REV_CLASS_MAP = {
      0: &quot;up&quot;,
      1: &quot;down&quot;,
      2: &quot;right&quot;,
      3: &quot;left&quot;,
      4: &quot;forward&quot;,
      5: &quot;back&quot;
  }
  
  
  def mapper(val):
      return REV_CLASS_MAP[val]
          if results.multi_hand_landmarks != None:
              new_row = []
              for handLandmarks in results.multi_hand_landmarks:
                  try:
                      for point in handsModule.HandLandmark:
                          normalizedLandmark = handLandmarks.landmark[point]
                          pixelCoordinatesLandmark = drawingModule._normalized_to_pixel_coordinates(normalizedLandmark.x,
                                                                                                normalizedLandmark.y,
                                                                                                width_roi, height_roi)
                          new_row.extend(list(pixelCoordinatesLandmark))
                  except TypeError:
                      break
  
              if new_row:
                  pred = model.predict(new_row)
                  move_code = np.argmax(pred[0])
                  user_move_name = mapper(move_code)
  </code></pre>
  <p>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀</p>