当我将 dropout 添加到输入层时发生异常。
其他线程中提到了该异常,也与其他问题相关,最常见的建议解决方案是降级 Keras 版本。此异常是否有解决方法?
def baseline_model() :
model = Sequential()
model.add(Dropout(0.35)) #THIS LINE CAUSES THE EXCEPTION
model.add(Dense(200, input_dim=1200, kernel_initializer='normal', activation='relu'))
model.add(Dropout(0.8))
rms = RMSprop(lr = 0.00050)
model.add(Dense(1, kernel_initializer='normal', activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer=rms, metrics=['accuracy'])
return model
模型在加载权重文件时抛出以下异常:
ValueError: You are trying to load a weight file containing 2 layers into a model with 0 layers.