deep-text-corrector icon indicating copy to clipboard operation
deep-text-corrector copied to clipboard

Cannot execute your code due to missing attribute '_linear'

Open tle4336 opened this issue 8 years ago • 10 comments

Hi Alex, thanks for your great work!! I tried executing your main execution file ("textcorrector.ipnyb"), but I keep getting this error message: AttributeError: module 'tensorflow.python.ops.rnn_cell' has no attribute '_linear'. I ran your code using Jupyter Notebook, with Python's 3.5 version (latest), and tensorflow's 1.2.1 version (latest too). I don't understand why it keeps saying certain module lacks of the essential attribute to run your code. Could you please help explain why this happens, Alex?

tle4336 avatar Jul 14 '17 02:07 tle4336

So I was able to fix it now by deleting the entire 'linear =...' line. Now, another problem appears: ImportError: cannot import name 'TextCorrectorModel', when I execute the main file. I load the file 'text_corrector_models.py', and then run that file alone. I got the error message: ArgumentError: argument --config: conflicting option string: --config. These errors, surprisingly, stem from seq2seq.py. But the thing is: I already successful ran the seq2seq.py file. When I got rid of the line import seq2seq in the 'text_corrector_models.py' and ran this Python script, no error was announced!

Cannot believe running your execution file takes that much effort, but I still cannot give up;(

tle4336 avatar Jul 14 '17 03:07 tle4336

go to seq2seq.py

add in to seq2seq: from tensorflow.python.ops import rnn_cell_impl change line #70 to linear = rnn_cell_impl._linear

you will need seq2seq for text_corrector_models.py

ssonia1 avatar Sep 01 '17 13:09 ssonia1

Hi, I'm getting the same error as in the title. I did as you suggest @largevaluesoftwo but I still get this: linear = rnn_cell_impl._linear # pylint: disable=protected-access AttributeError: 'module' object has no attribute '_linear' any suggestion? Thanks

manucarbonell avatar Nov 13 '17 12:11 manucarbonell

This stems from the fact that newer versions of TF don't have the _linear op implemented in rnn_cell_impl anymore. If you downgrade your TF to 1.2 it should definitely work. Alternatively, i assume you can substitute _linear with a standard TF layer such as tf.contrib.layers.fully_connected. I am working on that currently for my own model

anthnyprschka avatar Feb 05 '18 12:02 anthnyprschka

@anthnyprschka i am newer , could you tell me more details of the substitude _linear with tf.xxxxx.fully_connected . thanks very much!

SkylerHuang avatar May 10 '18 08:05 SkylerHuang

Hi, I use tf 1.8 and solve this by changing seq2seq.py:

from tensorflow.contrib.rnn.python.ops import core_rnn_cell
linear = core_rnn_cell._Linear

This works for me.

lutein avatar Aug 21 '18 08:08 lutein

@lutein many thanks. This works for me, too.

kino-ngoo avatar Aug 30 '18 08:08 kino-ngoo

@lutein any alternative in tensorflow 2?? I was unable to find the _linear function in tensorflow add on.

githubpiyush avatar Jan 29 '20 12:01 githubpiyush

Yes, Any alternative in tensorflow 2 for _linear function ?

madhu-korada avatar Apr 22 '20 22:04 madhu-korada

How about TensorFlow 2 ? I can't find _Linear in TF2 too.

shuDaoNan9 avatar Mar 18 '21 12:03 shuDaoNan9