tf.nn.static_rnn
tf.nn.static_rnn(
cell,
inputs,
initial_state=None,
dtype=None,
sequence_length=None,
scope=None
)
由RNNCell cell声明创建递归神经网络。初始状态可以被提供。如果提供了sequence_length vector,将自动进行计算。
输入参数:
cell: RNNCell实例
inputs: A length T list of inputs, each a Tensor of shape [batch_size, input_size], or a nested tuple of such elements.
sequence_length: 声明输入中每个序列的长度。整形向量,size [batch_size], values in [0, T).
输出参数:
outputs: 长度为T的List,每个元素为一个X对应的输出结果,或者是每个元素嵌套的元组
state: 最后一个隐状态
tf.nn.static_bidirectional_rnn
tf.nn.static_bidirectional_rnn(
cell_fw,
cell_bw,
inputs,
initial_state_fw=None,
initial_state_bw=None,
dtype=None,
sequence_length=None,
scope=None
)
盗用一张图用于说明
输出参数:
输出结果为元组 (outputs, output_state_fw, output_state_bw) 其中,outputs is a length T list of outputs (one for each input), 长度采用depth-concatenated forward and backward的输出结果. output_state_fw is the final state of the forward rnn. output_state_bw is the final state of the backward rnn.