简体   繁体   English

Tensorflow模块导入错误:AttributeError:模块'tensorflow.python.ops.nn'没有属性'rnn_cell'

[英]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.

相关问题 Tensorflow:AttributeError:模块“tensorflow.python.ops.nn”没有属性“softmax_cross_entropy_with_logits_v2” - Tensorflow: AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'softmax_cross_entropy_with_logits_v2' AttributeError: 'module' 对象没有属性 'rnn_cell' - AttributeError: 'module' object has no attribute 'rnn_cell' AttributeError: 模块“tensorflow.python.framework.ops”没有属性“RegisterShape” - AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'RegisterShape' AttributeError:模块'tensorflow.python.framework.ops'没有属性'_TensorLike' - AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' 导入 tensorflow 失败(模块“tensorflow_core.contrib”没有属性“cudnn_rnn_ops”) - failed to import tensorflow (module 'tensorflow_core.contrib' has no attribute 'cudnn_rnn_ops') tensorflow 中的 add 方法问题:AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' - Issue with add method in tensorflow : AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' Tensorflow:AttributeError:模块'tensorflow.python'没有属性'control_flow_ops' - Tensorflow: AttributeError: module 'tensorflow.python' has no attribute 'control_flow_ops' AttributeError:模块“ tensorflow.contrib.rnn”没有属性“ BasicLSTMCell” - AttributeError: module 'tensorflow.contrib.rnn' has no attribute 'BasicLSTMCell' AttributeError:模块“ tensorflow.contrib.rnn”没有属性“ GRUCell” - AttributeError: Module 'tensorflow.contrib.rnn' has no attribute 'GRUCell' Tensorflow导入错误AttributeError:'模块'对象没有属性'导出器' - Tensorflow import error AttributeError: 'module' object has no attribute 'Exporter'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM