[英]Tensorflow Module Import error: AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'
When attempting to pass my RNN call, I call tf.nn.rnn_cell and I receive the following error: 尝试通过我的RNN呼叫时,我调用tf.nn.rnn_cell并收到以下错误:
AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'
Which is odd, because I'm sure I imported everything correctly: 这很奇怪,因为我确定我正确地导入了一切:
from __future__ import print_function, division
from tensorflow.contrib import rnn
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
But looking at the docs, things have moved around between tensorflow versions. 但是看看文档,事情已经在tensorflow版本之间移动了。
what would you all recommend to fix this?? 你会推荐什么来解决这个问题?
Line, I'm getting the error against: 行,我收到错误:
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)]
)
Specifically: 特别:
tf.nn.rnn_cell
I'm using anaconda 3 to manage all of this so, the dependancies should all be taken care of. 我正在使用anaconda 3来管理所有这些,所有的依赖都应该得到照顾。 I have already tried working around a damn rank/shape error with Tensor shapes which took ages to resolve. 我已经尝试用Tensor形状来解决该死的等级/形状错误,需要花费很长时间才能解决。
Cheers in advance. 提前干杯。
Replace tf.nn.rnn_cell
with tf.contrib.rnn
用tf.nn.rnn_cell
替换tf.contrib.rnn
Since version 1.0, rnn
implemented as part of the contrib module. 从版本1.0开始, rnn
作为contrib模块的一部分实现。
More information can be found here https://www.tensorflow.org/api_guides/python/contrib.rnn 更多信息可以在这里找到https://www.tensorflow.org/api_guides/python/contrib.rnn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.