我正在研究关系提取。众所周知,tf.nn.bidirectional_dynamic_rnn
的输出包括outputs
和output_states
。在阅读代码时,我发现有些使用outputs
,而有些使用output_states
。哪一个更好?我该如何选择?
情况1:
outputs, states = tf.nn.bidirectional_dynamic_rnn(fw_cell, bw_cell, x, sequence_length = sequence_length, dtype = tf.float32, scope = 'dynamic-bi-rnn')
fw_outputs, bw_outputs = outputs
outputs = tf.add(fw_outputs, bw_outputs)
案例2:
_, states = tf.nn.bidirectional_dynamic_rnn(fw_cell, bw_cell, x, sequence_length = sequence_length, dtype = tf.float32, scope = 'dynamic-bi-rnn')
fw_states, bw_states = states
if isinstance(fw_states, tuple):
fw_states = fw_states[0]
bw_states = bw_states[0]
return tf.concat([fw_states, bw_states], axis = 1)
请帮助我,非常感谢!