random.shuffle(training)
training = np.array(training)
X = list(training[:,0])
Y = list(training[:,1])
print("Training data created")
def create_model():
model = Sequential()
model.add(Dense(128, input_shape=(len(X[0])), activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(len(Y[0]), activation='softmax'))
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer='sgd', metrics=['accuracy'])
return model
model = KerasClassifier(build_fn=create_model, verbose=0)
batch_size = [0, 1, 2, 3, 4, 5]
epochs = [100, 200, 300]
param_grid = dict(batch_size=batch_size, epochs=epochs)
grid = GridSearchCV(estimator=model, param_grid=param_grid, n_jobs=-1, cv=3)
grid.fit(X, Y)
File "", line 7, in grid.fit(X, Y)
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_search.py", line 722, in fit self._run_search(evaluate_candidates)
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_search.py", line 1191, in _run_search evaluate_candidates(ParameterGrid(self.param_grid))
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_search.py", line 711, in evaluate_candidates cv.split(X, y, groups)))
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/externals/joblib/parallel.py", line 930, in call self.retrieve()
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/externals/joblib/parallel.py", line 833, in retrieve self._output.extend(job.get(timeout=self.timeout))
File "/Users/mounaelboukili/anaconda3/lib/python3.7/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 521, in wrap_future_result return future.result(timeout=timeout)
File "/Users/mounaelboukili/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 432, in result return self.__get_result()
File "/Users/mounaelboukili/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exception
TypeError: 'int' object is not iterable