title: Error when checking input: expected conv2d_input to have 4 dimensions, but got array with shape (28708, 1)
body: <p>I have a data set which looks something like:</p>
  
  <pre><code>  emotion   images
  0   0      [[70, 80, 82, 72, 58, 58, 60, 63, 54, 58, 60, ...
  1   0      [[151, 150, 147, 155, 148, 133, 111, 140, 170,...
  2   2      [[231, 212, 156, 164, 174, 138, 161, 173, 182,...
  3   4      [[24, 32, 36, 30, 32, 23, 19, 20, 30, 41, 21, ...
  4   6      [[4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 15, 2...
  </code></pre>
  
  <p>The emotion column is a categorical variable and images contain numpy array which represent images (size = (48, 48)). </p>
  
  <p>My task is Image Classification, for which I'm using keras. </p>
  
  <p>When I try:</p>
  
  <pre><code>model.fit(df['images'], df['emotion'], epochs= 10, batch_size = 32)
  </code></pre>
  
  <p>I get a Value Error:</p>
  
  <blockquote>
    <p>ValueError: Error when checking input: expected conv2d_1_input to have
    4 dimensions, but got array with shape (28708, 1)</p>
  </blockquote>
  
  <p>I understand that <code>fit()</code> expects numpy objects and I have tried using 'df.values' as suggested  <a href="https://stackoverflow.com/questions/43876770/pandas-dataframe-and-keras">here</a>. But it doesn't really work for me.</p>
  
  <p>I'd like to preprocess in a way that also batches my input with size 32. I don't know how to preprocess or reshape my data from here so that I can train it on my network with keras.</p>
  
  <p>how do I change my data to have 4 dimensions as is expected by my network?</p>
  
  <pre><code>model.summary()
  
      _________________________________________________________________
  Layer (type)                 Output Shape              Param #   
  =================================================================
  conv2d_7 (Conv2D)            (None, 46, 46, 64)        640       
  _________________________________________________________________
  activation_7 (Activation)    (None, 46, 46, 64)        0         
  _________________________________________________________________
  conv2d_8 (Conv2D)            (None, 44, 44, 32)        18464     
  _________________________________________________________________
  activation_8 (Activation)    (None, 44, 44, 32)        0         
  _________________________________________________________________
  max_pooling2d_4 (MaxPooling2 (None, 22, 22, 32)        0         
  _________________________________________________________________
  conv2d_9 (Conv2D)            (None, 20, 20, 32)        9248      
  _________________________________________________________________
  activation_9 (Activation)    (None, 20, 20, 32)        0         
  _________________________________________________________________
  conv2d_10 (Conv2D)           (None, 18, 18, 32)        9248      
  _________________________________________________________________
  activation_10 (Activation)   (None, 18, 18, 32)        0         
  _________________________________________________________________
  max_pooling2d_5 (MaxPooling2 (None, 9, 9, 32)          0         
  _________________________________________________________________
  conv2d_11 (Conv2D)           (None, 7, 7, 32)          9248      
  _________________________________________________________________
  activation_11 (Activation)   (None, 7, 7, 32)          0         
  _________________________________________________________________
  conv2d_12 (Conv2D)           (None, 5, 5, 32)          9248      
  _________________________________________________________________
  activation_12 (Activation)   (None, 5, 5, 32)          0         
  _________________________________________________________________
  max_pooling2d_6 (MaxPooling2 (None, 2, 2, 32)          0         
  _________________________________________________________________
  flatten_1 (Flatten)          (None, 128)               0         
  _________________________________________________________________
  dense_1 (Dense)              (None, 128)               16512     
  _________________________________________________________________
  activation_13 (Activation)   (None, 128)               0         
  _________________________________________________________________
  dense_2 (Dense)              (None, 7)                 903       
  _________________________________________________________________
  activation_14 (Activation)   (None, 7)                 0         
  =================================================================
  Total params: 73,511
  Trainable params: 73,511
  Non-trainable params: 0
  </code></pre>
  
  <p>My model code:</p>
  
  <pre><code>model = Sequential()
  model.add(Conv2D(64, (3,3), input_shape = (48, 48, 1)))
  model.add(Activation('relu'))
  model.add(Conv2D(32, (3,3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size = (2, 2)))
  
  model.add(Conv2D(32, (3,3)))
  model.add(Activation('relu'))
  model.add(Conv2D(32, (3,3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size = (2, 2)))
  
  model.add(Conv2D(32, (3,3)))
  model.add(Activation('relu'))
  model.add(Conv2D(32, (3,3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D (pool_size = (2, 2)))
  
  
  model.add(Flatten())
  model.add(Dense(units = 128))
  model.add(Activation('relu'))
  model.add(Dense(units= 7))
  model.add(Activation('softmax'))
  model.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])
  </code></pre>