如何提取dynamic_lstm的在各个时刻的隐含状态输出?
Created by: lch1234
假如如下使用 dynamic_lstm:
import paddle.fluid as fluid emb_dim = 256 vocab_size = 10000 hidden_dim = 512
data = fluid.layers.data(name='x', shape=[1], dtype='int32', lod_level=1) emb = fluid.layers.embedding(input=data, size=[vocab_size, emb_dim], is_sparse=True)
forward_proj = fluid.layers.fc(input=emb, size=hidden_dim * 4, bias_attr=False) forward, _ = fluid.layers.dynamic_lstm( input=forward_proj, size=hidden_dim * 4, use_peepholes=False) 文档中说: 返回的forward是(T x D)形,且LoD保持与输入一致。
如何提取 隐藏状态(hidden state)即上面的 forward中各个时刻(t=1, 2,...T)的输出呢?