Keras return_state和return_sequences

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huuuuuuuu/article/details/87631101

1.常见的4中结构

在这里插入图片描述

  • one to one:
    • model.add(Dense(output_size, input_shape=input_shape))
  • one to many:
    • model.add(RepeatVector(number_of_times, input_shape=input_shape))
      model.add(LSTM(output_size, return_sequences=True))
  • many to one:
    • model = Sequential()
      model.add(LSTM(1, input_shape=(timesteps, data_dim)))
  • many to many:
    • model = Sequential()
      model.add(LSTM(1, input_shape=(timesteps, data_dim), return_sequences=True))

ref:https://stackoverflow.com/questions/43034960/many-to-one-and-many-to-many-lstm-examples-in-keras

2.return_sequences 和 return_state

return_sequences:

  • 每一步都有隐藏状态 a,不同结构计算方式不同
  • 默认FALSE,为TRUE时可以达到 *-to-many的效果

return_state:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/huuuuuuuu/article/details/87631101