0
$\begingroup$

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.add(Dense(64, activation='relu', input_dim=5))  
        model_mag.add(Dropout(0.5))
        model_mag.add(Dense(64, activation='relu'))
        model_mag.add(Dropout(0.5))
        model_mag.add(Dense(64, activation='relu'))
        model_mag.add(Dense(1))
        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.

$\endgroup$
1
  • $\begingroup$ Try this : clf = KerasRegressor(build_fn=model_build,nb_epoch=100) $\endgroup$
    – enterML
    May 31, 2017 at 10:02

1 Answer 1

1
$\begingroup$

You have put nb_epoch in fit.

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

$\endgroup$
1
  • $\begingroup$ I took away that part and tried just running clf.fit(X_train,y_train) and still have the same problem, any ideas? $\endgroup$ May 30, 2017 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.