tensorflow1.x调试到2.x,相关问题

1,No module named "tensorflow.examples"

原因:
TensorFlow包下缺少tutorials文件夹

解决方法:

  1. 使用命令找到tensorflow的路径      
    import tensorflow as tf
    print(tf._ _path_ _)

    2.参照一下链接

https://blog.csdn.net/wuyanne/article/details/115033677?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163886440316780261931972%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=163886440316780261931972&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-14-115033677.pc_search_result_cache&utm_term=tensorflow.examples&spm=1018.2226.3001.4187

2,AttributeError: module 'tensorflow' has no attribute 'log'

If you can find the exact line where tf.log is used, try tf.math.log instead.

3,ModuleNotFoundError: No module named 'tensorflow.contrib'

在tensorflow2.0版本中可以直接去掉如下代码,在2.0版本中会自动开启

import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()

4,AttributeError: module 'tensorflow' has no attribute 'layers'

将如下代码:
tf.layers.conv2d()
转换为如下代码:
tf.compat.v1.layers.conv2d()

5,AttributeError: module 'tensorflow._api.v2.train' has no attribute 'AdamOptimizer'

将如下代码:
tf.train.AdamOptimizer()
转变为如下代码:
tf.optimizers.Adam()

6,TypeError: minimize() missing 1 required positional argument: 'var_list'

值得思考

7,AttributeError: module 'tensorflow' has no attribute 'get_variable'

将下列代码
tf.get_variable()
转换为
tf.compat.v1.get_variable()

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值