【问题标题】:RNN: What is the use of return_sequences in LSTM layer in Keras FrameworkRNN:Keras框架中LSTM层的return_sequences有什么用
【发布时间】:2018-12-24 21:12:15
【问题描述】:

我在 RNN 工作。我有来自某个站点的以下代码行。 如果你观察到第二层没有“returnSequence”参数。

我假设返回序列是强制性的,因为它应该返回序列。 你能说出为什么没有定义吗?

第一层 LSTM:

regressor.add(LSTM(units = 30, return_sequences = True))

第二层 LSTM:

regressor.add(LSTM(units = 30))

【问题讨论】:

  • 您的问题不清楚。为什么你认为它“应该返回序列”?
  • 感谢您的回复。就像在 RNN 中的每个时间步一样,输出被输入到自身中,因此我假设 return_sequence 应该是真的。你能告诉那这个 return_sequence 到底是做什么的吗?

标签: machine-learning keras lstm recurrent-neural-network rnn


【解决方案1】:

return_sequences参数设置为False(默认)时,网络只会输出hn,即最后时间步的隐藏状态。否则,网络将输出隐藏状态的完整序列,[h1, h2, ..., hn]。层的内部方程不变。参考documentation

【讨论】:

  • 谢谢康斯坦丁。明白了。
  • 在实际使用方面,将return_sequences 设置为TrueFalse 有何作用?
猜你喜欢
  • 1970-01-01
  • 2020-09-23
  • 1970-01-01
  • 1970-01-01
  • 2023-01-03
  • 2019-08-18
  • 1970-01-01
  • 2020-06-10
  • 2020-09-02
相关资源
最近更新 更多