keras Tensorflow InceptionV4 ImportError:无法从“tensorflow.python.framework”导入名称“tensor”

cclgggtu  于 2023-08-06  发布在  Python
关注(0)|答案(1)|浏览(327)
from inceptionV4 import *

字符串
我正在使用tensorflow InceptionV4,但收到此错误消息。Tensorflow-inceptionV4

ImportError
cannot import name 'tensor' from 'tensorflow.python.framework' (C:\Users\zxc\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\__init__.py)
  File "C:\Labbb\inception\model_tensorflow_official.py", line 28, in <module>
    import tf_slim as slim
  File "C:\Labbb\inception\main.py", line 14, in <module>
    from model_tensorflow_official import *
ImportError: cannot import name 'tensor' from 'tensorflow.python.framework' (C:\Users\zxc\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\__init__.py)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import tensorflow.compat.v1 as tf
import tf_slim as slim

from nets import inception_utils

的数据
我试过tensorflow2.5 + keras2.5和tensorflow2.2 +keras2.3.1,它们不工作
在之前的错误消息检测中,我在tf_slim\nets中没有“inception_utils”文件
tf-slim中,也没有inception_utils

pw136qt2

pw136qt21#

因此,当安装tf-models-official或slim时,也会安装tf_slim包(https://github.com/google-research/tf-slim/tree/master)。这里,更新了tf_slim.layers.utils模块,以从'tensorflow.python. framework'导入'tensor'。然而,“Tensor”模块仅从tensorflow==2.13开始存在。你可以通过比较这里的不同分支来看到这一点:https://github.com/tensorflow/tensorflow/tree/r2.13/tensorflow/python/framework
我通过安装tensorflow==2.13使它工作:
1.第一个月

  1. tf-models-official==2.13(可能不需要)
  2. cd /path/to/clone/repo
  3. git clone https://github.com/tensorflow/models/(如此处所述https://github.com/tensorflow/models/tree/master/research/slim
    在我的Python脚本中:
import sys
sys.path.append("/path/to/clone/repo/models/research/slim")
from nets.inception_v4 import *

字符串

相关问题