当我尝试传递我的 RNN 调用时,我调用了 tf.nn.rnn_cell 并收到以下错误:
AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'
这很奇怪,因为我确定我正确导入了所有内容:
from __future__ import print_function, division
from tensorflow.contrib import rnn
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
但是查看文档,事情在 tensorflow 版本之间发生了变化。
你们会推荐什么来解决这个问题??
行,我得到的错误是:
state_per_layer_list = tf.unstack(init_state, axis=0)
rnn_tuple_state = tuple(
[tf.nn.rnn_cell.LSTMStateTuple(state_per_layer_list[idx][0], state_per_layer_list[idx][1])
for idx in range(num_layers)]
)
具体来说:
tf.nn.rnn_cell
我正在使用 anaconda 3 来管理所有这些,因此,所有依赖项都应该得到处理。我已经尝试使用 Tensor 形状来解决该死的等级/形状错误,这需要很长时间才能解决。
提前干杯。
最佳答案
用tf.contrib.rnn
替换tf.nn.rnn_cell
从 1.0 版开始,rnn
作为 contrib 模块的一部分实现。
更多信息可以在这里找到 https://www.tensorflow.org/api_guides/python/contrib.rnn
关于python - Tensorflow 模块导入错误 : AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47898147/