title: Keras ValueError: expected dense_1 to have shape (3,) but got array with shape (4,)
body: <p>I've been trying to figure out how to use Keras when reading data from a .csv[1]. I have the following code:</p>
  
  <pre><code>dataframe = pd.read_csv("iris.csv", header=None)
  dataset = dataframe.values
  X = dataset[:, 0:4].astype(float)
  Y = dataset[:, 4]
  
  # encode class values as integers
  encoder = LabelEncoder()
  encoder.fit(Y)
  encoded_Y = encoder.transform(Y)
  # convert integers to dummy variables (i.e. one hot encoded)
  one_hot_y = keras.utils.to_categorical(encoded_Y)
  
  X_train = X[:100]
  X_test = X[50:]
  
  Y_train = one_hot_y[:100]
  Y_test = one_hot_y[50:]
  
  print(X_train.shape)
  
  
  # define baseline model
  def baseline_model():
      # create model
      model = keras.models.Sequential()
      model.add(keras.layers.Dense(8, input_shape=(4, ), activation='relu'))
      model.add(keras.layers.Dense(3, activation='softmax'))
      # Compile model
      model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
      return model
  
  model = baseline_model()
  
  history = model.fit(X_train, X_test, epochs=5)
  
  test_loss, test_acc = model.evaluate(Y_train, Y_test)
  print('Test accuracy:', test_acc)
  </code></pre>
  
  <p>However, when I run this, I get the error:</p>
  
  <pre><code>ValueError: Error when checking target: expected dense_1 to have shape (3,) but got array with shape (4,)
  </code></pre>
  
  <p>I find this odd as I was sure to set input_shape=(4, ). Any help with this would be appreciated.</p>
  
  <p>[1] The CSV looks as follows:</p>
  
  <p>5.1,3.5,1.4,0.2,Iris-setosa
  ...</p>