handwriting-synthesis icon indicating copy to clipboard operation
handwriting-synthesis copied to clipboard

ImportError: cannot import name '_like_rnncell'

Open ssell opened this issue 7 years ago • 8 comments

System:

  • Windows 10 1803
  • Python 3.6.2
  • TensorFlow 1.11.0

Error:

Traceback (most recent call last):
File "test.py", line 1, in <module>
    import demo
File "C:\Projects\ml\handwriting-synthesis\demo.py", line 9, in <module>
    from rnn import rnn
File "C:\Projects\ml\handwriting-synthesis\rnn.py", line 10, in <module>
    from rnn_ops import rnn_free_run
File "C:\Projects\ml\handwriting-synthesis\rnn_ops.py", line 9, in <module>
    from tensorflow.python.ops.rnn_cell_impl import _concat, _like_rnncell
ImportError: cannot import name '_like_rnncell'

Solution:

Hacky, but I simply removed the reference to _like_rnncell on lines 9, 29, and 30 in rnn_ops.py. Seems to run fine afterwards (though this led to encountering Issue #17).

ssell avatar Oct 18 '18 19:10 ssell

_like_rnncell has been deprecated as of TensorFlow version 1.0+

Use rnn_cell_impl.assert_like_rnncell instead of _like_rnncell. Check this for reference.

Jertlok avatar Jun 29 '19 06:06 Jertlok

best method is make tehsorflow version is 1.6.0, if not there will be many issues.

mzw2018 avatar Oct 23 '19 02:10 mzw2018

@ssell I think you need to install and use the tensorflow version 1.6.0. otherwise you cannot fix this problem thoroughly reference for install tensorflow 1.6.0: https://stackoverflow.com/questions/38896424/tensorflow-not-found-using-pip

defi0x1 avatar Apr 10 '20 05:04 defi0x1

@docongminh, Looks like we can indeed use the latest version of tensorflow with a few changes to the rnn_ops.py file. Please refer to Support the latest tensorflow #27 pull request for more info.

samvatsar avatar Apr 11 '20 03:04 samvatsar

@docongminh How do I do that. I'm not getting it.

swainsubrat avatar May 25 '20 02:05 swainsubrat

@docongminh How do I do that. I'm not getting it.

Please make changes to your files as per the changes made in #27 (go to files changed tab).

samvatsar avatar May 25 '20 05:05 samvatsar

I tried to emulate your setup and I still have the error:

Python 3.6.2 TensorFlow 1.11.0

AttributeError: module 'tensorflow.compat' has no attribute 'v1'

WindowsNT avatar Feb 13 '21 10:02 WindowsNT

Instead of doing much changes in the core project.

Just use this ==> from tensorflow.python.ops.rnn_cell_impl import assert_like_rnncell as _like_rnncell

abhiprojectz avatar Jun 25 '22 05:06 abhiprojectz