【发布时间】:2020-08-08 13:26:00
【问题描述】:
为了实现多层LSTM网络,我通常使用如下代码:
def lstm_cell():
return tf.contrib.rnn.LayerNormBasicLSTMCell(model_settings['rnn_size'])
attn_cell = lstm_cell
def attn_cell():
return tf.contrib.rnn.DropoutWrapper(lstm_cell(), output_keep_prob=0.7)
cell = tf.contrib.rnn.MultiRNNCell([attn_cell() for _ in range(num_layers)], state_is_tuple=True)
outputs_, _ = tf.nn.dynamic_rnn(cell, x, dtype=tf.float32)
但是,这样一来,如果我想操纵隐藏层输出的排列,我就无法访问隐藏层输出。 有没有其他方法可以在不使用 tf.contrib.rnn.MultiRNNCell 的情况下制作多层 LSTM 网络?
【问题讨论】:
标签: tensorflow neural-network lstm