以下代码(取自- rnn.ipynb)
import tensorflow as tf
import numpy as np
tf.reset_default_graph()
# Create input data
X = np.random.randn(2, 10, 8)
# The second example is of length 6
X[1,6:] = 0
X_lengths = [10, 6]
cell = tf.contrib.rnn.LSTMCell(num_units=64, state_is_tuple=True)
outputs, states = tf.nn.bidirectional_dynamic_rnn(
cell_fw=cell,
cell_bw=cell,
dtype=tf.float64,
sequence_length=X_lengths,
inputs=X)
output_fw, output_bw = outputs
states_fw, states_bw = states
为提供了以下错误
tensorflow - 1.1 ( 2.7和3.5 )
ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.LSTMCell object at 0x10ce0c2b0>
with a different variable scope than its first use. First use of cell was with scope
'bidirectional_rnn/fw/lstm_cell', this attempt is with scope 'bidirectional_rnn/bw/lstm_cell'.
Please create a new instance of the cell if you would like it to use a different set of weights.
If before you were using: MultiRNNCell([LSTMCell(...)] * num_layers), change to:
MultiRNNCell([LSTMCell(...) for _ in range(num_layers)]). If before you were using the same cell
instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances
(one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use
existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation,
so this error will remain until then.)
,但它在中工作
tensorflow - 1.0.1用于python 3.5 (没有在python-2.7上进行测试)
我试过用我在网上找到的多个代码示例,但是
tf.nn.bidirectional_dynamic_rnn给出了与tensorflow - 1.1相同的错误
tensorflow 1.1中有bug吗?还是我只是遗漏了什么?
发布于 2017-05-22 09:16:43
很抱歉你碰到这个。我可以确认错误出现在1.1 (docker run -it gcr.io/tensorflow/tensorflow:1.1.0 python
)中,而不是在1.2 RC0 (docker run -it gcr.io/tensorflow/tensorflow:1.2.0-rc0 python
)中。
因此,目前看来,1.2-rc0或1.0.1是您的选择。
https://stackoverflow.com/questions/44106036
复制相似问题