栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Tensorflow:AttributeError: module ‘tensorflow’ has no attribute ‘contrib’解决方案

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Tensorflow:AttributeError: module ‘tensorflow’ has no attribute ‘contrib’解决方案

Tensorflow:AttributeError: module ‘tensorflow’ has no attribute 'contrib’解决方案

遇到问题:

在一次跑相关模型时遇到以下报错
prediction_fn=tf.contrib.layers.softmax,
AttributeError: module ‘tensorflow’ has no attribute ‘contrib’

于是到tensorfolw官网上查contrib模块,
https://tensorflow.google.cn/versions/r1.15/api_docs/python/tf/contrib
看到

意思大概是contrib已经在Tensorflow2.0弃用,它的子模块已经集成到TensorFlow core中,或分拆到TensorFlow_io和tensorflow_addons.有关说明可以查阅迁移指南,但下面那个迁移指南我打不开。
于是我在这个页面搜索layers.softmax的信息,得到如下信息:于是将tf.contrib.layers.softmax改tf.keras.layers.softmax,再次运行没有报错。

据此推测其他有关Tensorflow中contrib的问题也可以用此方法解决。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/350833.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号