请有人说明为什么我的以下代码出现属性错误?
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) ```
答案 0 :(得分:0)
您有错字:buil_fn
应该是build_fn
此外,nb_epochs
应该是nb_epoch
#fitting model for k-fold cross validation
classifier = KerasClassifier(build_fn = build_classifier,nb_epoch = 100,
batch_size=10)