title: confusion_matrix() library is giving ValueError
body: <p>When trying to get confusion matrix for a ConvNet constantly getting the same error. </p>
  
  <pre><code>from keras.preprocessing.image import ImageDataGenerator
  from keras.models import Sequential
  from keras.layers import Conv2D, MaxPooling2D
  from keras.layers import Activation, Dropout, Flatten, Dense
  from keras import backend as K
  import numpy as np
  from keras.preprocessing import image
  from sklearn.metrics import classification_report, confusion_matrix
  img_width, img_height = 150, 150
  
  train_data_dir = "train"
  validation_data_dir = "test"
  nb_train_samples = 2000
  nb_validation_samples = 400
  epochs = 50
  batch_size = 40 #16
  
  if K.image_data_format() == 'channels_first':
      input_shape = (3, img_width, img_height)
  else:
      input_shape = (img_width, img_height, 3)
  
  train_datagen = ImageDataGenerator(
      rescale = 1. / 255,
      shear_range = 0.2,
      zoom_range= 0.2,
      horizontal_flip= True)
  
  test_datagen = ImageDataGenerator(rescale=1. / 255)
  
  train_generator = test_datagen.flow_from_directory(
      train_data_dir,
      target_size= (img_width, img_height),
      batch_size= batch_size,
      class_mode= 'binary')
  
  validation_generator = test_datagen.flow_from_directory(
      validation_data_dir,
      target_size= (img_width, img_height),
      batch_size= batch_size,
      class_mode= 'binary')`
  </code></pre>
  
  <p><strong><em>Applying CNN Layers</em></strong>        <code>...</code></p>
  
  <pre><code>model.compile(loss= 'binary_crossentropy',
      optimizer= 'rmsprop',
      metrics= ['accuracy'] )
  
  `model.fit_generator(
      train_generator,
      steps_per_epoch= nb_train_samples // batch_size,
      epochs= epochs,
      validation_data= validation_generator,
      validation_steps= nb_validation_samples // batch_size)
  
  Y_pred = model.predict_generator(validation_generator, nb_validation_samples // batch_size+1)
  y_pred = np.argmax(Y_pred, axis=1)
  print('Confusion Matrix')
  print(confusion_matrix(validation_generator.classes, y_pred))`
  </code></pre>
  
  <p>Getting error mentioned below but don't know how to resolve it</p>
  
  <p><strong>ValueError: Found input variables with inconsistent numbers of samples: [400, 440]</strong></p>