Attention-OCR
Attention-OCR copied to clipboard
module 'tensorflow.contrib.rnn.python.ops.rnn_cell' has no attribute '_linear'
File "......./attention-OCR-master/src/model/seq2seq.py", line 75, in
Use tensorflow 1.2 or lower.
The API for Tensorflow has changed in more recent versions. To fix this, edit src/model/seq2seq.py
by
- Changing
linear = rnn_cell._linear
tolinear = core_rnn_cell._linear
(line 73) - Including the import
from tensorflow.contrib.rnn.python.ops import core_rnn_cell
Hope that helps!
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
tornn_cell_impl._linear
it works!
CNN outdim: (?, ?, 512)
Traceback (most recent call last):
File "src/launcher.py", line 146, in
Please help me on, solving this issue
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)
Some following changes may have to be made after performing the aforementioned changes: In seq2seq_model.py make following changes as well:
- 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) Hope it helps!
The API for Tensorflow has changed in more recent versions. To fix this, edit
src/model/seq2seq.py
by
- Changing
linear = rnn_cell._linear
tolinear = core_rnn_cell._linear
(line 73)- Including the import
from tensorflow.contrib.rnn.python.ops import core_rnn_cell
Hope that helps!
thanks itworks
I did the changes above, but I get this error:
Traceback (most recent call last):
File "src/launcher.py", line 146, in
The API for Tensorflow has changed in more recent versions. To fix this, edit
src/model/seq2seq.py
by
- Changing
linear = rnn_cell._linear
tolinear = core_rnn_cell._linear
(line 73)- Including the import
from tensorflow.contrib.rnn.python.ops import core_rnn_cell
Hope that helps!
This really helped...thanks :)
if x.shape.ndims is None:
AttributeError: '_Linear' object has no attribute 'shape'
thanks all! use tensorflow-gpu==1.4
- [ 1 ] change
from tensorflow.contrib.rnn.python.ops import rnn, rnn_cell
tofrom tensorflow.python.ops import rnn_cell_impl
- [ 2 ] change
rnn_cell._linear
tornn_cell_impl._linear
it works!
It doesn't work in tensorflow-gpu==1.14...
Some following changes may have to be made after performing the aforementioned changes: In seq2seq_model.py make following changes as well:
- 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) Hope it helps!
Thanks! It helped
A complete list of changes including @mamingjie-China and @masonsun :--
-
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
-
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)
what could be done to resolve this
这是来自QQ邮箱的假期自动回复邮件。你好,邮件已收到,我将尽快给你回复。谢谢~