Glennismade
Glennismade

Reputation: 117

Tensorflow TypeError: 'module' object is not callable - tf.contrib.rnn

Had an issue with Attribute errors calling:

tf.nn.rnn(cell, inputs_series, initial_state=rnn_tuple_state)

Received an Attribute error:

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'rnn'

Changed this to:

tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)

However, now I receive the following error:

TypeError: 'module' object is not callable

against the following line:

states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)

the code looks as follows:

# Forward passes
cell = tf.contrib.rnn.LSTMCell(state_size, state_is_tuple=True)
cell = tf.contrib.rnn.MultiRNNCell([cell] * num_layers, state_is_tuple=True)
states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)

Full Error:

Traceback (most recent call last):
  File "/Users/glennhealy/PycharmProjects/lstm2/lstm2.py", line 49, in <module>
    states_series, current_state = tf.contrib.rnn(cell, inputs_series, initial_state=rnn_tuple_state)
TypeError: 'module' object is not callable

Any Ideas??

tf.nn.rnn doesn't work, but neither does tf.contrib.rnn

Cheers in advance

Updated with more information based on responses

Looking at this, I have tried all the options in the tensorflgw_RNN information and I'm getting this error for a lot of them:

TypeError: static_bidirectional_rnn() got an unexpected keyword argument 'initial_state'

so, now I'm lost.

Upvotes: 1

Views: 1448

Answers (1)

Milo Lu
Milo Lu

Reputation: 3356

According to the document https://www.tensorflow.org/api_guides/python/contrib.rnn

TensorFlow provides a number of methods for constructing Recurrent Neural Networks.

tf.contrib.rnn.static_rnn
tf.contrib.rnn.static_state_saving_rnn
tf.contrib.rnn.static_bidirectional_rnn
tf.contrib.rnn.stack_bidirectional_dynamic_rnn

Try this

tf.contrib.rnn.static_rnn(cell, inputs_series, initial_state=rnn_tuple_state)

or

tf.nn.static_rnn(cell, inputs_series, initial_state=rnn_tuple_state)

Upvotes: 1

Related Questions