tensorflow - 模块“tensorflow”没有属性“contrib”
问题描述
我正在尝试使用 Tensorflow Object-Detection-API 训练我自己的自定义对象检测器
我在我的谷歌计算引擎中使用“pip install tensorflow”安装了 tensorflow。然后我按照该站点上的所有说明进行操作:https ://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html
当我尝试使用 train.py 时,我收到以下错误消息:
回溯(最后一次调用):文件“train.py”,第 49 行,从 object_detection.builders import dataset_builder 文件“/usr/local/lib/python3.6/dist-packages/object_detection-0.1->py3.6 .egg/object_detection/builders/dataset_builder.py”,第 27 行,从 object_detection.data_decoders 导入 tf_example_decoder 文件“/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection /data_decoders/tf_example_decoder.py",第 27 行,在 slim_example_decoder = tf.contrib.slim.tfexample_decoder AttributeError: 模块 'tensorflow' 没有属性 'contrib'
当我尝试学习 tensorflow 版本时,我也会得到不同的结果。
python3 -c '将张量流导入为 tf; 打印(tf。版本)':2.0.0-dev20190422
当我使用
pip3 显示张量流:
名称:tensorflow 版本:1.13.1 总结:TensorFlow是一个开源的机器学习框架,适合所有人。主页:https ://www.tensorflow.org/ 作者:Google Inc. 作者电子邮件:opensource@google.com 许可证:Apache 2.0 位置:/usr/local/lib/python3.6/dist-packages 要求: gast, astor, absl-py, tensorflow-estimator, keras-preprocessing, grpcio, 六, keras-applications, wheel, numpy, tensorboard, protobuf, termcolor
sudo python3 train.py --logtostderr --train_dir=training/ --
pipeline_config_path=training/ssd_inception_v2_coco.config
我应该怎么做才能解决这个问题?除了以下内容,我找不到有关此错误消息的任何信息:tensorflow 'module' object has no attribute 'contrib'
解决方案
tf.contrib
从 TF 2.0 alpha 开始已移出 TF。
看看这些 tf 2.0 发行说明https://github.com/tensorflow/tensorflow/releases/tag/v2.0.0-alpha0
您可以使用tf_upgrade_v2
脚本
将 TF 1.x 代码升级到 TF 2.x :/ /www.tensorflow.org/alpha/guide/upgrade
推荐阅读
- c# - 重定向控制台输入时如何模仿 ReadKey 行为?
- spring-boot - Hibernate CriteriaBuilder 无法比较 2 时间 - 数据类型时间和日期时间在大于或等于运算符中不兼容
- django - 使用 django 作为离子应用程序的后端时出现 CORS 错误
- latex - 包含 Tikz 的图像不会移动
- assembly - 如果我使用调用,实模式中断有效,如果我使用 INT,则无效(不会执行)
- javascript - Angular 7防止另一个函数使用“如果”条件
- javascript - 获取 React JS 中的类别列表
- react-native - 如何在 react-native-image-slider-box lib 中控制滑块的速度
- amazon-web-services - 如何发现使用的是 Amazon ElasticSearch 服务而不是随便的 ES?
- javascript - Puppeteer.js - scraping list of domains and storing data