model 跑不起来
来源:2-17 实战sklearn封装keras模型
慕码人3491233
2019-09-17
error message如下
‘NoneType' object has no attribute 'loss'
老师,请问这个问题怎么解决?
写回答
1回答
-
model没有compile?
def build_model(hidden_layers = 1, layer_size = 30, learning_rate = 3e-3): model = keras.models.Sequential() model.add(keras.layers.Dense(layer_size, activation='relu', input_shape=x_train.shape[1:])) for _ in range(hidden_layers - 1): model.add(keras.layers.Dense(layer_size, activation = 'relu')) model.add(keras.layers.Dense(1)) optimizer = keras.optimizers.SGD(learning_rate) model.compile(loss = 'mse', optimizer = optimizer) return model sklearn_model = KerasRegressor(build_fn = build_model)
012019-09-25
相似问题