我在这里使用了一些代码:https://github.com/monikkinom/ner-lstm和tensorflow。我认为代码是为旧版本的tensorflow编写的,我使用的是1.0.0版本。我使用tf_upgrade.py升级了github代码库中的model.py,但仍然收到错误:
output, _, _ = contrib_rnn.bidirectional_rnn(fw_cell, bw_cell,
AttributeError: 'module' object has no attribute 'bidirectional_rnn'这是在我将bidirectional_rnn调用更改为使用contrib_rnn之后,这是:
from tensorflow.contrib.rnn.python.ops import core_rnn as contrib_rnn以前的呼声是
output, _, _ = tf.nn.bidirectional_rnn(fw_cell, bw_cell,
tf.unpack(tf.transpose(self.input_data, perm=[1, 0, 2])),
dtype=tf.float32, sequence_length=self.length)这也不起作用。
我不得不将LSTMCell、DroputWrapper等更改为rnn.LSTMCell,但它们似乎工作得很好。这是我不知道如何改变的bidirectional_rnn。
发布于 2017-02-17 00:49:10
也许您可以尝试重新实现双向RNN,方法是简单地将两个单向RNN包装到一个类中,并在其中一个上设置参数"go_backwards=True“。然后,您还可以控制对输出执行的合并的类型。也许看一看https://github.com/fchollet/keras/blob/master/keras/layers/wrappers.py (请参阅Bidirectional类)中的实现可以帮助您入门。
发布于 2017-03-07 23:25:24
在RNN1.0中,您可以选择两个双向TensorFlow函数:
https://stackoverflow.com/questions/42279706
复制相似问题