title: ImageDataGenerator.flow: NumpyArrayIterator is set to use the data format convention "channels_last", when fixed causes fitting error
body: <p>My data is of shape <code>(60000, 1, 28, 28)</code> when I try to get them on batches as following:</p>
  
  <pre><code>gen = image.ImageDataGenerator()
  train_batches = gen.flow(x_train, y_train, batch_size=64)
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>ValueError: NumpyArrayIterator is set to use the data format convention "channels_last" (channels on axis 3), i.e. expected either 1, 3 or 4 channels on axis 3. However, it was passed an array with shape (60000, 1, 28, 28) (28 channels).
  </code></pre>
  
  <p>in order to get rid of it, I do: </p>
  
  <pre><code>train_batches = gen.flow(np.swapaxes(x_train,1,3), y_train, batch_size=64)
  </code></pre>
  
  <p>Although this does remove the above error, it generates the following error:</p>
  
  <pre><code>ValueError: Error when checking input: expected lambda_13_input to have shape (None, 1, 28, 28) but got array with shape (64, 28, 28, 1)
  </code></pre>
  
  <p>when doing:</p>
  
  <pre><code>lin_model.fit_generator(train_batches, train_batches.n, nb_epoch=1, 
                      validation_data= test_batches, nb_val_samples=test_batches.n)
  </code></pre>
  
  <p>I made sure that I added to my code ordering specifier:</p>
  
  <pre><code>import keras.backend as k
  k.image_dim_ordering() == 'th'
  </code></pre>
  
  <p>The full trace for that is:</p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-138-f8ea3b9faad4&gt; in &lt;module&gt;()
  ----&gt; 1 training_routine(lin_model)
  
  &lt;ipython-input-136-8b3171cd58ae&gt; in training_routine(model)
        2     model.optimizer.lr = 0.001
        3     model.fit_generator(train_batches, train_batches.n, nb_epoch=1, 
  ----&gt; 4                         validation_data= test_batches, nb_val_samples=test_batches.n)
        5     model.optimizer.lr = 0.1
        6     model.fit_generator(train_batches, train_batches.n, nb_epoch=1, 
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/legacy/interfaces.pyc in wrapper(*args, **kwargs)
       85                 warnings.warn('Update your `' + object_name +
       86                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
  ---&gt; 87             return func(*args, **kwargs)
       88         wrapper._original_function = func
       89         return wrapper
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/models.pyc in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, initial_epoch)
     1115                                         workers=workers,
     1116                                         use_multiprocessing=use_multiprocessing,
  -&gt; 1117                                         initial_epoch=initial_epoch)
     1118 
     1119     @interfaces.legacy_generator_methods_support
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/legacy/interfaces.pyc in wrapper(*args, **kwargs)
       85                 warnings.warn('Update your `' + object_name +
       86                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
  ---&gt; 87             return func(*args, **kwargs)
       88         wrapper._original_function = func
       89         return wrapper
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, initial_epoch)
     1838                     outs = self.train_on_batch(x, y,
     1839                                                sample_weight=sample_weight,
  -&gt; 1840                                                class_weight=class_weight)
     1841 
     1842                     if not isinstance(outs, list):
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in train_on_batch(self, x, y, sample_weight, class_weight)
     1557             sample_weight=sample_weight,
     1558             class_weight=class_weight,
  -&gt; 1559             check_batch_axis=True)
     1560         if self.uses_learning_phase and not isinstance(K.learning_phase(), int):
     1561             ins = x + y + sample_weights + [1.]
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size)
     1232                                     self._feed_input_shapes,
     1233                                     check_batch_axis=False,
  -&gt; 1234                                     exception_prefix='input')
     1235         y = _standardize_input_data(y, self._feed_output_names,
     1236                                     output_shapes,
  
  /home/matar/anaconda2/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
      138                             ' to have shape ' + str(shapes[i]) +
      139                             ' but got array with shape ' +
  --&gt; 140                             str(array.shape))
      141     return arrays
      142 
  
  ValueError: Error when checking input: expected lambda_13_input to have shape (None, 1, 28, 28) but got array with shape (64, 28, 28, 1)
  </code></pre>