0

Some one please clarify why I am getting attribute error for below code ?

from sklearn.model_selection import cross_val_score
from keras.models import Sequential
from keras.layers import Dense 

def build_classifier():   #one of the parameter for KerasClassifier
    classifier = Sequential() #initialising ANN by defining sequence of layers
    classifier.add(Dense(units=6,activation='relu',kernel_initializer='uniform',input_dim=11))
    classifier.add(Dense(units=6,activation='relu',kernel_initializer='uniform'))
    classifier.add(Dense(units=1,activation='sigmoid',kernel_initializer='uniform'))
    #compiling the ANN
    classifier.compile(optimizer = 'adam',loss = 'binary_crossentropy',
                      metrics=['accuracy'])
    return classifier

#fitting model for k-fold cross validation
classifier = KerasClassifier(buil_fn = build_classifier,nb_epochs = 100,
                            batch_size=10)  ```

  • similar issue --> https://stackoverflow.com/questions/44622857/why-am-i-getting-attributeerror-kerasclassifier-object-has-no-attribute-mode/44623291 – gold_cy Dec 15 '19 at 15:35
  • Please make sure the example actually runs (missing imports) and include the full traceback – Dr. Snoopy Dec 15 '19 at 16:09

1 Answers1

0

You have a typo: buil_fn should be build_fn

Also, nb_epochs should be nb_epoch

#fitting model for k-fold cross validation
classifier = KerasClassifier(build_fn = build_classifier,nb_epoch = 100,
                            batch_size=10) 
desertnaut
  • 57,590
  • 26
  • 140
  • 166