3

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.

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

5 Comments

Cheers that seemed to resolve the issue. you got an idea on how to handle this for the following: states_series, current_state = tf.nn.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
I receive an error saying no attribute RNN for it: AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn'
but when I use contrib.rnn I get another error saying: TypeError: 'module' object is not callable
try this tf.contrib.rnn.static_rnn
Cheers, that worked with a bit of fuss I got it working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.