title: Why does my keras model require a 3D list to predict?
body: <p>I've read a few answers on here saying that models require a 2D array to predict, even though we may just want one prediction. However, for as long as I can remember my models require 3D arrays to predict on. My input shape is 2D (shape 47145, 120), though when predicting I need to place my array inside two other lists in order for it to work correctly. Output shape is a 1D array.</p>
  
  <pre><code>model.predict([[1, 2, 3...]])[0]
  </code></pre>
  
  <p>doesn't work, but</p>
  
  <pre><code>model.predict([[[1, 2, 3...]]])[0][0]
  </code></pre>
  
  <p>does. I don't mind it, and it predicts perfectly fine for me, but having to add an extra <code>[0][0]</code> after each line of prediction has led me to question if this is the expected behavior.</p>
  
  <p>Here's the error message I get when I try to predict on a 2D array:</p>
  
  <pre><code>In [154] a = [0] * 120
  
  In [155]: model.predict([a])
  ValueError: Error when checking input: expected dense_1_input to have shape (120,) but got array with shape (1,) 
  </code></pre>
  
  <p>Here is the code I use to create my model:</p>
  
  <pre><code>opt = keras.optimizers.Adam(lr=0.00055, decay=1e-6)
  
  layer_num = 5
  nodes = 80
  
  model = Sequential()
  model.add(Dense(x_train.shape[1], activation="relu", input_shape=(x_train.shape[1:])))
  for i in range(layer_num):
      model.add(Dense(nodes, activation="relu"))
  model.add(Dense(1, activation='linear'))
  
  tensorboard = TensorBoard(log_dir="logs\{}-layers-{}-nodes-{}-opt-adam-decay2".format(
                            layer_num, nodes, 'relu'), histogram_freq=0, write_graph=True)
  callbacks = [tensorboard]
  
  model.compile(loss='mean_squared_error', optimizer=opt, metrics=['mean_absolute_error'])
  model.fit(x_train, y_train, shuffle=True, batch_size=64, validation_data=(x_test, y_test),
                                                           callbacks=callbacks, epochs=80)
  </code></pre>
  
  <p>My shapes:</p>
  
  <pre><code>In [146]: x_train.shape
  Out[146]: (47145, 120)
  
  In [147]: y_train.shape
  Out[147]: (47145,)
  
  In [148]: x_train[0]
  Out[148]: 
  array([0.51050081, 0.48233333, 0.12769333, 0.12920803, 0.13162067,
         0.12359916, 0.51050081, 0.488     , 0.12325733, 0.14299455,
         0.13225505, 0.12455976, 0.51050081, 0.49366667, 0.12325733,
         0.14299455, 0.13225505, 0.12455976, 0.51050081, 0.499     ,
         0.13022811, 0.13016997, 0.13352359, 0.12584059, 0.51050081,
         0.49566667, 0.12896078, 0.11991025, 0.13225505, 0.13096383,
         0.51050081, 0.49233333, 0.12769333, 0.11638345, 0.12940056,
         0.13032347, 0.51050081, 0.48933333, 0.12325733, 0.12407822,
         0.12718045, 0.12808203, 0.51050081, 0.49266667, 0.12547533,
         0.12696372, 0.12718045, 0.12231832, 0.51050081, 0.48933333,
         0.12547533, 0.12696372, 0.12718045, 0.12231832, 0.51050081,
         0.486     , 0.12737644, 0.12568135, 0.12654618, 0.12231832,
         0.51050081, 0.48266667, 0.12769333, 0.12119272, 0.12496034,
         0.12584059, 0.51050081, 0.47933333, 0.13181244, 0.12151326,
         0.12718045, 0.12936276, 0.51050081, 0.476     , 0.12896078,
         0.12696372, 0.1284491 , 0.12391928, 0.51050081, 0.47266667,
         0.12896078, 0.12696372, 0.1284491 , 0.12391928, 0.51050081,
         0.46933333, 0.126109  , 0.12728437, 0.12654618, 0.11783545,
         0.51050081, 0.466     , 0.12547533, 0.12343704, 0.12305742,
         0.11143137, 0.51050081, 0.46266667, 0.13022811, 0.11926895,
         0.11988585, 0.11879605, 0.51050081, 0.45933333, 0.12737644,
         0.12407822, 0.12147158, 0.12968299, 0.51050081, 0.456     ,
         0.126109  , 0.12568135, 0.12718045, 0.14761449, 0.51050081,
         0.45266667, 0.126109  , 0.12568135, 0.12718045, 0.14761449])
  </code></pre>