NameError: global name 'linear' is not defined

2.3k Views Asked by At

I am trying to run an implementation of attention mechanism by Google DeepMind. However it is based on an older version of TensorFlow and I am getting this error

from tensorflow.models.rnn.rnn_cell import RNNCell, linear
concat = linear([inputs, h, self.c], 4 * self._num_units, True)

NameError: global name 'linear' is not defined

I couldn't find the linear model/function in the new tensorflow documentation. Can anyone help me with this? Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

You need to use the tf.nn.rnn_cell._linear function to make the code work. Have a look at this tutorial for a sample usage.