【问题标题】:('Keyword argument not understood:', 'W_regularizer')('关键字参数不理解:','W_regularizer')
【发布时间】:2021-10-02 08:25:48
【问题描述】:

我的代码:

model = Sequential()
#model.add(Dense(1, activation="relu", input_dim = X_train.shape[1]))
model.add(Dense(1, input_dim = X_train.shape[1], W_regularizer = l1(0.001)))

model.compile(loss = "mse", optimizer = "adam")

我得到了错误

TypeError: ('Keyword argument not understood:', 'W_regularizer')

【问题讨论】:

  • TensorFlow中没有W_regularizer这样的参数,去掉那个。

标签: python machine-learning keras


【解决方案1】:

在最近的 Keras 版本中,W_regularizer 被替换为 kernel_regularizer
所以试试这样:

model = Sequential()
#model.add(Dense(1, activation="relu", input_dim = X_train.shape[1]))
model.add(Dense(1, input_dim = X_train.shape[1], kernel_regularizer = l1(0.001)))

model.compile(loss = "mse", optimizer = "adam")

【讨论】:

    猜你喜欢
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 2021-08-17
    • 2020-08-12
    • 2018-12-29
    • 2021-01-28
    相关资源
    最近更新 更多