将TensorFlow1的代码自动升到TensorFlow2

参考:https://www.tensorflow.org/guide/upgrade

TensorFlow创建了 tf_upgrade_v2 工具,可将旧版代码转换为新的API

tf_upgrade_v2 \
--intree my_project/ \
--outtree my_project_v2/ \
--reportfile report.txt

对单个文件:

tf_upgrade_v2 
--infile ResNet50.py 
--outfile ResNet50_v2.py

对文件夹,将“--infile”改为“--intree”即可。

但是对于contrib模块,需要单独调整:

参考:https://stackoverflow.com/questions/64255154/change-tf-contrib-layers-xavier-initializer-to-2-0-0

the TF2 replacement for  

tf.contrib.layers.xavier_initializer() is tf.keras.initializers.glorot_normal(Xavier and Glorot are 2 names for the same initializer algorithm) documentation link.

TensorFlow与cuda 对应版本查询:

https://www.tensorflow.org/install/source#gpu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值