如何在 LSTM 中为每个输入生成 1 个以上的输出?

How to generate more than 1 output per input in LSTM?

假设这是我的模型:

_________________________________________________________________ 
Layer (type)                 Output Shape              Param #    ================================================================= 
embedding_16 (Embedding)     (None, 10, 500)          71500      _________________________________________________________________ 
lstm_31 (LSTM)               (None, 10, 500)          2002000    _________________________________________________________________ 
dropout_15 (Dropout)         (None, 10, 500)          0          _________________________________________________________________ 
time_distributed_16          (None, 10, 500)          250500    _________________________________________________________________ 
softmax (Activation)         (None, 10, 500)           0     =================================================================

但我想在我的最后一层:

softmax (Activation)         (None, 100, 1000)           0

几个小时以来我一直在尝试这样做。我不知道这是否可能。我不认为你可以改变 LSTM 的输出大小(查看它的模型)但是有没有我可以添加的层以便它生成,比如说,每个输入 10 个输出?

简单来说,假设我希望我的模型为我输入的每个词生成 10 个词。我希望我能够解释。

这里有不同的查看 "multiple output" 的方法(根据 "here",我猜测您正在使用 keras 库 - 从打印输出看来是这样)。

在一个简单的例子中,例如Dense(10) 层将解决它。 "secret sauce" 使用 TimeDistributed 层包装器,如本 中所述。

另一种方法需要使用 keras 的功能 API。 docs 中解释了如何获取多个输出。