【问题标题】:How to add Dropout in Keras functional model?如何在 Keras 功能模型中添加 Dropout?
【发布时间】:2018-07-18 00:18:10
【问题描述】:

假设我在 Keras 中有一个这样的 LSTM 层:

x = Input(shape=(input_shape), dtype='int32')

x = LSTM(128,return_sequences=True)(x)

现在我正在尝试使用以下方法将 Dropout 添加到该层:

X = Dropout(0.5)

但这会产生错误,我假设上面的行是重新定义 X 而不是向其中添加 Dropout。 如何解决这个问题?

【问题讨论】:

    标签: python machine-learning neural-network keras rnn


    【解决方案1】:

    只需像这样添加x = Dropout(0.5)(x)

    x = Input(shape=(input_shape), dtype='int32')
    x = LSTM(128,return_sequences=True)(x)
    x = Dropout(0.5)(x)
    

    【讨论】:

      猜你喜欢
      • 2021-03-27
      • 2021-06-06
      • 1970-01-01
      • 2019-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多