Search code examples
machine-learningtensorflowdeep-learningrecurrent-neural-network

Tensorflow error in import tf.nn.rnn_cell


I am using Tensorflow 1.0.0 and Python 3.5. When I try to do:

cell = tf.nn.rnn_cell.BasicRNNCell(state_size)

I get the following error:

AttributeError

  <ipython-input-25-41a20d8458a7> in <module>()

      1 # Forward pass
      2 print(tf.__version__)
  --->3 cell = tf.nn.rnn_cell.BasicRNNCell(state_size)
      4 states_series, current_state = tf.nn.dynamic_rnn(cell, inputs_series, initial_state = init_state)
  AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell'

Can someone help me?


Solution

  • TensorFlow changes a lot of APIs before 1.0.

    You'll need to replace tf.nn.rnn_cell.BasicLSTMCell by tf.contrib.rnn.BasicLSTMCell