作者:手机用户2502941293 | 来源:互联网 | 2024-10-16 12:39
这是错误
File "emotion.py",line 64,in
model.add(Conv2D(num_features,kernal_size=(3,3),activation='relu',input_shape=(X_train.shape[1:])))
File "C:\Users\Mohan Bishnoi\Anaconda3\envs\mlthings\lib\site-packages\keras\legacy\interfaces.py",line 91,in wrapper
return func(*args,**kwargs)
TypeError: __init__() missing 1 required positional argument: 'kernel_size'
这是我的代码,在此我遇到错误...
model=Sequential()
model.add(Conv2D(num_features,input_shape=(X_train.shape[1:])))
model.add(Conv2D(num_features,activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2),strides=(2,2)))
model.add(Dropout(0.5))
model.add(Dense(num_labels,activation='softmax'))
model.compile(loss=categorical_crossentropy,optimizer=Adam(),metrics=['accuracy'])
model.fit(X_train,train_y,batch_size=batch_size,epochs=epochs,verbose=1,validation_data=(X_test,test_y),shuffle=True)
fer_json=model.to_json()
with open("fer_json","w") as json_file:
json_file.write(fer_json)
model.save_weights("fer.h5")