gpt4 book ai didi

tensorflow - Keras 导入错误 Tensorflow 后端

转载 作者:行者123 更新时间:2023-12-02 01:20:29 25 4
gpt4 key购买 nike

    ---------------------------------------------------------------------------
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'

根据这篇文章 enter link description here,似乎问题出在 Keras 而不是 Tensorflow我想知道这是否已修复?

最佳答案

这是Keras和tensorflow之间的问题。你应该改变这个 fix使用类似的东西

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

当前访问 ctc 操作的“官方”方式在 tf.nn 中,例如,tf.nn.ctc_loss

关于tensorflow - Keras 导入错误 Tensorflow 后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40538920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com