简体   繁体   中英

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:

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.

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. I have already tried working around a damn rank/shape error with Tensor shapes which took ages to resolve.

Cheers in advance.

Replace tf.nn.rnn_cell with tf.contrib.rnn

Since version 1.0, rnn implemented as part of the contrib module.

More information can be found here https://www.tensorflow.org/api_guides/python/contrib.rnn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM