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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TensorFlow 1.x 版本主要有以下几个重要版本: 1.0:2017 年 2 月发布,支持分布式训练和推理、GPU、TPU 加速等功能。 1.1:2017 年 3 月发布,添加了对 CUDA 8 和 cuDNN 6 的支持,也增加了一些新特性。 1.2:2017 年 5 月发布,引入了 Eager Execution 模式,即动态图模式,方便调试和交互式探索。 1.3:2017 年 8 月发布,添加了对 CUDA 9 和 cuDNN 7 的支持,同时也增加了一些新特性。 1.4:2017 年 11 月发布,引入了 TensorFlow Debugger,即 tfdbg,可以帮助用户更容易地调试模型。 1.5:2018 年 1 月发布,引入了 TensorFlow Lite,即 TensorFlow 的移动端和嵌入式设备版本。 1.6:2018 年 3 月发布,添加了对 CUDA 9.1 和 cuDNN 7.1 的支持,同时也增加了一些新特性。 1.7:2018 年 3 月发布,添加了对 CUDA 9.2 和 cuDNN 7.2 的支持,也增加了一些新特性。 1.8:2018 年 4 月发布,添加了对 CUDA 9.2 和 cuDNN 7.1 的支持,同时也增加了一些新特性。 1.9:2018 年 6 月发布,添加了对 CUDA 9.2 和 cuDNN 7.1 的支持,同时也增加了一些新特性。 1.10:2018 年 7 月发布,添加了对 CUDA 9.2 和 cuDNN 7.2 的支持,同时也增加了一些新特性。 1.11:2018 年 11 月发布,添加了对 CUDA 10 和 cuDNN 7.3 的支持,也增加了一些新特性。 1.12:2018 年 12 月发布,添加了对 CUDA 10 和 cuDNN 7.4 的支持,同时也增加了一些新特性。 1.13:2019 年 2 月发布,添加了对 CUDA 10 和 cuDNN 7.4 的支持,同时也增加了一些新特性。 1.14:2019 年 3 月发布,添加了对 CUDA 10.1 和 cuDNN 7.5 的支持,同时也增加了一些新特性。 1.15:2019 年 10 月发布,添加了对 TensorFlow 2.0 的兼容性支持,同时也增加了一些新特性。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值