da03 / Attention-OCR

Visual Attention based OCR
MIT License
1.11k stars 362 forks source link

module 'tensorflow.contrib.rnn.python.ops.rnn_cell' has no attribute '_linear' #71

Open dongdql opened 6 years ago

dongdql commented 6 years ago

File "......./attention-OCR-master/src/model/seq2seq.py", line 75, in linear = rnn_cell._linear # pylint: disable=protected-access

EzequielAdrianM commented 6 years ago

Use tensorflow 1.2 or lower.

masonsun commented 6 years ago

The API for Tensorflow has changed in more recent versions. To fix this, edit src/model/seq2seq.py by

  1. Changing linear = rnn_cell._linear to linear = core_rnn_cell._linear (line 73)
  2. Including the import from tensorflow.contrib.rnn.python.ops import core_rnn_cell

Hope that helps!

dongdql commented 6 years ago

thanks all! use tensorflow-gpu==1.4

it works!

balajiwix commented 6 years ago

CNN outdim: (?, ?, 512) Traceback (most recent call last): File "src/launcher.py", line 146, in main(sys.argv[1:], exp_config.ExpConfig) File "src/launcher.py", line 142, in main session = sess) File "E:\Data_Science\OCR\Attention-OCR-master\src\model\model.py", line 151, in init use_gru = use_gru) File "E:\Data_Science\OCR\Attention-OCR-master\src\model\seq2seq_model.py", line 87, in init single_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(attn_num_hidden, forget_bias=0.0, state_is_tuple=False) AttributeError: module 'tensorflow.contrib.rnn' has no attribute 'core_rnn_cell'

Please help me on, solving this issue

kulkarnivishal commented 6 years ago

replace : single_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(attn_num_hidden, forget_bias=0.0, state_is_tuple=False) with : tf.contrib.rnn.BasicLSTMCell(attn_num_hidden, forget_bias=0.0, state_is_tuple=False)

famunir commented 6 years ago

Some following changes may have to be made after performing the aforementioned changes: In _seq2seqmodel.py make following changes as well:

1) Replace _cell = tf.contrib.rnn.core_rnn_cell.MultiRNNCell([single_cell] attn_num_layers, state_istuple=False) With _cell = tf.contrib.rnn.MultiRNNCell([single_cell] attn_num_layers, state_istuple=False) 2) Replace _lstm_fw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) With _lstm_fw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) 3) Replace _lstm_bw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) With _lstm_bw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) Hope it helps!

dongdql commented 5 years ago

The API for Tensorflow has changed in more recent versions. To fix this, edit src/model/seq2seq.py by

  1. Changing linear = rnn_cell._linear to linear = core_rnn_cell._linear (line 73)
  2. Including the import from tensorflow.contrib.rnn.python.ops import core_rnn_cell

Hope that helps!

thanks itworks

jameswan commented 5 years ago

I did the changes above, but I get this error:

Traceback (most recent call last): File "src/launcher.py", line 146, in main(sys.argv[1:], exp_config.ExpConfig) File "src/launcher.py", line 142, in main session = sess) File "G:\Attention-OCR-master\src\model\model.py", line 151, in init use_gru = use_gru) File "G:\Attention-OCR-master\src\model\seq2seq_model.py", line 92, in init cell = single_cell UnboundLocalError: local variable 'single_cell' referenced before assignment

AKhileshPothuri commented 5 years ago

The API for Tensorflow has changed in more recent versions. To fix this, edit src/model/seq2seq.py by

  1. Changing linear = rnn_cell._linear to linear = core_rnn_cell._linear (line 73)
  2. Including the import from tensorflow.contrib.rnn.python.ops import core_rnn_cell

Hope that helps!

This really helped...thanks :)

Lanme commented 5 years ago
if x.shape.ndims is None:

AttributeError: '_Linear' object has no attribute 'shape'

mamingjie-China commented 5 years ago

thanks all! use tensorflow-gpu==1.4

  • [ 1 ] change

from tensorflow.contrib.rnn.python.ops import rnn, rnn_cell to from tensorflow.python.ops import rnn_cell_impl

  • [ 2 ] change rnn_cell._linear to rnn_cell_impl._linear

it works!

It doesn't work in tensorflow-gpu==1.14...

AshutoshUpadhya commented 4 years ago

Some following changes may have to be made after performing the aforementioned changes: In _seq2seqmodel.py make following changes as well:

  1. Replace _cell = tf.contrib.rnn.core_rnn_cell.MultiRNNCell([single_cell] attn_num_layers, state_istuple=False) With _cell = tf.contrib.rnn.MultiRNNCell([single_cell] attn_num_layers, state_istuple=False)
  2. Replace _lstm_fw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) With _lstm_fw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False)
  3. Replace _lstm_bw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) With _lstm_bw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_istuple=False) Hope it helps!

Thanks! It helped

AshutoshUpadhya commented 4 years ago

A complete list of changes including @mamingjie-China and @masonsun :--

  1. In file seq2seq.py change linear = rnn_cell._linear to linear = core_rnn_cell._linear (line 73) import from tensorflow.contrib.rnn.python.ops import core_rnn_cell

  2. in file seq2seq_model.py Replace cell = tf.contrib.rnn.core_rnn_cell.MultiRNNCell([single_cell] attn_num_layers, state_is_tuple=False) With cell = tf.contrib.rnn.MultiRNNCell([single_cell] attn_num_layers, state_is_tuple=False) Replace lstm_fw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_is_tuple=False) With lstm_fw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_is_tuple=False) Replace lstm_bw_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(num_hidden, forget_bias=0.0, state_is_tuple=False) With lstm_bw_cell = tf.contrib.rnn.BasicLSTMCell(num_hidden, forget_bias=0.0, state_is_tuple=False)

jb1812 commented 2 years ago

image image

what could be done to resolve this

dongdql commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。你好,邮件已收到,我将尽快给你回复。谢谢~