title: ValueError: Error when checking target: expected dense_1 to have 2 dimensions, but got array with shape (68, 50, 50, 50, 1)
body: <p>I'm trying to build a convolutional network that will work on a 3D voxel grid.  I try to add a fully connected layer but get an error:</p>
  
  <p>ValueError: Error when checking target: expected dense_1 to have 2 dimensions, but got array with shape (68, 50, 50, 50, 1)</p>
  
  <p>How can this be happening when I have a flatten layer first?  Shouldn't my input to the dense layer at that point be, well, flat?</p>
  
  <pre><code>x, y = load_data(directory)
  x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=42)
  model = Sequential()
  model.add(Convolution3D(1, kernel_size=(3, 3, 3), activation='relu',
                          border_mode='same', name='conv1',
                          input_shape=(50, 50, 50, 1)))
  model.add(MaxPooling3D(pool_size=(2, 2, 2)))
  model.add(Flatten())
  model.add(Dense(32))
  model.compile(
      loss='mean_squared_error',
      optimizer='adam',
      metrics=['accuracy']
      )
  model.fit(
      x_train,
      y_train,
      epochs=10,
      batch_size=32,
      )
  model.evaluate(x_test, y_test)
  </code></pre>
  
  
  
  <pre><code>_________________________________________________________________
  Layer (type)                 Output Shape              Param #   
  =================================================================
  conv1 (Conv3D)               (None, 50, 50, 50, 1)     28        
  _________________________________________________________________
  max_pooling3d_1 (MaxPooling3 (None, 25, 25, 25, 1)     0         
  _________________________________________________________________
  flatten_1 (Flatten)          (None, 15625)             0         
  _________________________________________________________________
  dense_1 (Dense)              (None, 32)                500032    
  =================================================================
  </code></pre>