什么时候使用birnn的输出和状态?用于关系提取任务

时间:2019-04-23 12:18:23

标签: python nlp recurrent-neural-network

我正在研究关系提取。众所周知,tf.nn.bidirectional_dynamic_rnn的输出包括outputsoutput_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)

请帮助我,非常感谢!

0 个答案:

没有答案