title: Keras expected sequential_2 to have shape (None, 2) but got array with shape (32, 1)
body: <p>I have build a model with keras using pre-trained VGG16</p>
  
  <pre><code> model = Sequential()
  model.add(ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height)))
  
  model.add(Convolution2D(64, 3, 3, activation='relu', name='conv1_1'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(64, 3, 3, activation='relu', name='conv1_2'))
  model.add(MaxPooling2D((2, 2), strides=(2, 2)))
  
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(128, 3, 3, activation='relu', name='conv2_1'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(128, 3, 3, activation='relu', name='conv2_2'))
  model.add(MaxPooling2D((2, 2), strides=(2, 2)))
  
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_1'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_2'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(256, 3, 3, activation='relu', name='conv3_3'))
  model.add(MaxPooling2D((2, 2), strides=(2, 2)))
  
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_1'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_2'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv4_3'))
  model.add(MaxPooling2D((2, 2), strides=(2, 2)))
  
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_1'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_2'))
  model.add(ZeroPadding2D((1, 1)))
  model.add(Convolution2D(512, 3, 3, activation='relu', name='conv5_3'))
  model.add(MaxPooling2D((2, 2), strides=(2, 2)))
  
  # load the weights of the VGG16 networks
  # (trained on ImageNet, won the ILSVRC competition in 2014)
  # note: when there is a complete match between your model definition
  # and your weight savefile, you can simply call model.load_weights(filename)
  assert os.path.exists(vgg_model), 'Model weights not found (see "weights_path" variable in script).'
  f = h5py.File(vgg_model)
  for k in range(f.attrs['nb_layers']):
      if k &gt;= len(model.layers):
          # we don't look at the last (fully-connected) layers in the savefile
          break
      g = f['layer_{}'.format(k)]
      weights = [g['param_{}'.format(p)] for p in range(g.attrs['nb_params'])]
      model.layers[k].set_weights(weights)
  f.close()
  print('Model loaded.')
  
  # build a classifier model to put on top of the convolutional model
  top_model = Sequential()
  top_model.add(Flatten(input_shape=model.output_shape[1:]))
  top_model.add(Dense(256, activation='relu'))
  top_model.add(Dropout(0.5))
  top_model.add(Dense(2, activation='softmax'))
  </code></pre>
  
  <p>but while running the model with fit function it was throwing an exception </p>
  
  <pre><code>expected sequential_2 to have shape (None, 2) but got array with shape (32, 1)
  </code></pre>
  
  <p>What was the issue here (Note: I was using the fit from directory function to train my model).</p>