title: GridSearchCV for number of neurons
body: <p>I am trying to learn by myself how to grid-search number of neurons in a basic multi-layered neural networks. I am using GridSearchCV and KerasClasifier of Python as well as Keras. The code below works for other data sets very well but I could not make it work for Iris dataset for some reasons and I cannot find it why, I am missing out something here. The result I get is: </p>
  
  <p><code>Best: 0.000000 using {'n_neurons': 3}
  0.000000 (0.000000) with: {'n_neurons': 3}
  0.000000 (0.000000) with: {'n_neurons': 5}</code></p>
  
  <pre><code>from pandas import read_csv
  
  import numpy
  from sklearn.preprocessing import LabelEncoder
  from sklearn.preprocessing import StandardScaler
  
  from keras.wrappers.scikit_learn import KerasClassifier
  from keras.models import Sequential
  from keras.layers import Dense
  from keras.utils import np_utils
  from sklearn.model_selection import GridSearchCV
  
  dataframe=read_csv("iris.csv", header=None)
  dataset=dataframe.values
  X=dataset[:,0:4].astype(float)
  Y=dataset[:,4]
  
  seed=7
  numpy.random.seed(seed)
  
  #encode class values as integers
  encoder = LabelEncoder()
  encoder.fit(Y)
  encoded_Y = encoder.transform(Y)
  
  #one-hot encoding
  dummy_y = np_utils.to_categorical(encoded_Y)
  
  #scale the data
  scaler = StandardScaler()
  X = scaler.fit_transform(X)
  
  def create_model(n_neurons=1):
      #create model
      model = Sequential()
      model.add(Dense(n_neurons, input_dim=X.shape[1], activation='relu')) # hidden layer
      model.add(Dense(3, activation='softmax')) # output layer
      # Compile model
      model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
      return model
  
  model = KerasClassifier(build_fn=create_model, epochs=100, batch_size=10, initial_epoch=0, verbose=0)
  # define the grid search parameters
  neurons=[3, 5]
  
  #this does 3-fold classification. One can change k. 
  param_grid = dict(n_neurons=neurons)
  grid = GridSearchCV(estimator=model, param_grid=param_grid, n_jobs=-1)
  grid_result = grid.fit(X, dummy_y)
  # summarize results
  print("Best: %f using %s" % (grid_result.best_score_, grid_result.best_params_))
  means = grid_result.cv_results_['mean_test_score']
  stds = grid_result.cv_results_['std_test_score']
  params = grid_result.cv_results_['params']
  for mean, stdev, param in zip(means, stds, params):
      print("%f (%f) with: %r" % (mean, stdev, param))
  </code></pre>
  
  <p>For the purpose of illustration and computational efficiency I search only for two values.  I sincerely apologize for asking such a simple question. I am new to Python, switched from R, by the way because I realized that Deep Learning community is using python.</p>