【问题标题】:LSTM equivalent of return_sequence = True in newer version of Keras在较新版本的 Keras 中,LSTM 等效于 return_sequence = True
【发布时间】:2018-05-26 17:48:27
【问题描述】:

我使用 tensorflow 作为 keras 的后端。在 LSTM 的一个教程中,它说

regressor.add(LSTM(units = 50, return_sequence = True, input_shape = Xtrain))

看看它说的新 LSTM 语法

keras.layers.LSTM(units, activation='tanh', recurrent_activation='hard_sigmoid', 
                  use_bias=True, kernel_initializer='glorot_uniform', 
                  recurrent_initializer='orthogonal', bias_initializer='zeros', 
                  unit_forget_bias=True, kernel_regularizer=None, 
                  recurrent_regularizer=None, bias_regularizer=None, 
                  activity_regularizer=None, kernel_constraint=None, 
                  recurrent_constraint=None, bias_constraint=None, dropout=0.0, 
                  recurrent_dropout=0.0, implementation=1, return_sequences=False, 
                  return_state=False, go_backwards=False, 
                  stateful=False, unroll=False)

有人可以在较新版本中提供与上述代码等效的代码吗?

【问题讨论】:

    标签: keras lstm keras-layer rnn


    【解决方案1】:

    return_sequence 是一个拼写错误的参数,它应该是return_sequences(注意尾随的s)。这个论点在最新版本中仍然存在,甚至在master 中。

    input_shape 也支持作为 kw 参数(同义词:input_dim)。

    所以只需使用

    LSTM(units = 50, return_sequences = True, input_shape = Xtrain)
    

    【讨论】:

      猜你喜欢
      • 2019-01-15
      • 1970-01-01
      • 2019-03-11
      • 2022-07-23
      • 2017-10-27
      • 2019-07-30
      • 1970-01-01
      • 2011-08-22
      • 2023-03-30
      相关资源
      最近更新 更多