# Error in Keras Fitting

I am having the problem with the following python code which uses the library keras, and I have not been able to find a solution online:

       def model_build():
model_mag=Sequential()
model_mag.compile(loss=losses.mean_squared_error,optimizer='sgd')
return model_mag
clf = KerasRegressor(build_fn=model_build(),nb_epoch=100)
# here is the error
clf.fit(X_train,y_train, nb_epoch=20)


I know that X_train and y_train are well defined above and I can run other classifier methods just fine with them so they are not the problem. It keeps throwing me the following error in the fit line and I can't figure out why:

TypeError: call() takes exactly 2 arguments (1 given)

I am giving two arguments though.

• Try this : clf = KerasRegressor(build_fn=model_build,nb_epoch=100) – enterML May 31 '17 at 10:02

You have put nb_epoch in fit.
You have to remove nb_epoch from fit, and let it only in KerasRegressor.