调用属性错误时出现问题:
tf.nn.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
收到属性错误:
AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn'
将其更改为:
tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
但是,现在我收到以下错误:
TypeError: 'module' object is not callable
针对以下行:
states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
代码如下:
# Forward passes
cell = tf.contrib.rnn.LSTMCell(state_size, state_is_tuple=True)
cell = tf.contrib.rnn.MultiRNNCell([cell] * num_layers, state_is_tuple=True)
states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
完整错误:
Traceback (most recent call last):
File "/Users/glennhealy/PycharmProjects/lstm2/lstm2.py", line 49, in <module>
states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
TypeError: 'module' object is not callable
任何想法?
tf.nn.rnn 不起作用,但 tf.contrib.rnn
也不起作用提前干杯
根据回复更新了更多信息
看看这个,我已经尝试了tensorflgw_RNN信息中的所有选项,我收到了很多这样的错误:
TypeError: static_bidirectional_rnn() got an unexpected keyword argument 'initial_state'
所以,现在我迷路了。
答案 0 :(得分:1)
根据该文件 https://www.tensorflow.org/api_guides/python/contrib.rnn
TensorFlow提供了许多构建递归神经网络的方法。
tf.contrib.rnn.static_rnn
tf.contrib.rnn.static_state_saving_rnn
tf.contrib.rnn.static_bidirectional_rnn
tf.contrib.rnn.stack_bidirectional_dynamic_rnn
试试这个
tf.contrib.rnn.static_rnn(cell, inputs_series, initial_state=rnn_tuple_state)
或
tf.nn.static_rnn(cell, inputs_series, initial_state=rnn_tuple_state)