gpt4 book ai didi

python - Tensorflow 类型错误 : 'module' object is not callable - tf. contrib.rnn

转载 作者:太空宇宙 更新时间:2023-11-03 14:21:39 25 4
gpt4 key购买 nike

调用属性错误时遇到问题:

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'

所以,现在我迷路了。

最佳答案

根据文档 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)

关于python - Tensorflow 类型错误 : 'module' object is not callable - tf. contrib.rnn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47907148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com