Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras Import Error Tensorflow backend

    ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/Users/CJL/anaconda3/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in <module>()
      4 try:
----> 5     from tensorflow.python.ops import ctc_ops as ctc
      6 except ImportError:

ImportError: cannot import name 'ctc_ops'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-10-c74e2bd4ca71> in <module>()
----> 1 import keras

/Users/CJL/anaconda3/lib/python3.5/site-packages/keras/__init__.py in <module>()
      1 from __future__ import absolute_import
----> 2 from . import backend
      3 from . import datasets
      4 from . import engine
      5 from . import layers

/Users/CJL/anaconda3/lib/python3.5/site-packages/keras/backend/__init__.py in <module>()
     67 elif _BACKEND == 'tensorflow':
     68     sys.stderr.write('Using TensorFlow backend.\n')
---> 69     from .tensorflow_backend import *
     70 else:
     71     raise Exception('Unknown backend: ' + str(_BACKEND))

/Users/CJL/anaconda3/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in <module>()
      5     from tensorflow.python.ops import ctc_ops as ctc
      6 except ImportError:
----> 7     import tensorflow.contrib.ctc as ctc
      8 
      9 import numpy as np

ImportError: No module named 'tensorflow.contrib.ctc'

Seems like is an problem with Keras and not Tensorflow according to this post enter link description here I was wondering if this has been fixed yet?

like image 290
Char Avatar asked Feb 20 '26 16:02

Char


1 Answers

This is a problem between Keras and tensorflow. You should change this fix to use something like

if hasattr(tf.contrib, 'ctc'):
  ctc = tf.contrib.ctc  # old version
else:
  ctc = tf.nn  # New official version.

The current "official" way to access the ctc operations are in tf.nn, for instance, tf.nn.ctc_loss.

like image 200
drpng Avatar answered Feb 24 '26 18:02

drpng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!