当前位置:网站首页>【Tensorflow2】tensorflow1.x-tensorflow2.x一些接口的转变
【Tensorflow2】tensorflow1.x-tensorflow2.x一些接口的转变
2022-08-08 22:58:00 【摇曳的树】
1. AttributeError: ‘BatchDataset’ object has no attribute ‘make_one_shot_iterator’
tensorflow1.X版本写法:
data_it = dataset.make_one_shot_iterator()
tensorflow2.X版本写法:
data_it = tf.compat.v1.data.make_one_shot_iterator(dataset)
2. AttributeError: module ‘tensorflow_core._api.v2.random’ has no attribute ‘set_random_seed’
tensorflow1.X版本写法:
seed=tf.random.set_random_seed(1234)
tensorflow2.X版本写法:
seed=tf.random.set_seed(1234)
3. AttributeError: module ‘tensorflow’ has no attribute ‘decode_raw’
tensorflow1.X版本写法:
gt_binary_image = tf.decode_raw(features['gt_binary_image_raw'], tf.uint8)
tensorflow2.X版本写法:
gt_binary_image = tf.io.decode_raw(features['gt_binary_image_raw'], tf.uint8)
4. AttributeError: module ‘tensorflow’ has no attribute ‘FixedLenFeature’
tensorflow1.X版本写法:
'gt_image_raw': tf.FixedLenFeature([], tf.string)
tensorflow2.X版本写法:
'gt_image_raw': tf.io.FixedLenFeature([], tf.string)
5. AttributeError: module ‘tensorflow’ has no attribute ‘parse_single_example’
tensorflow1.X版本写法:
features = tf.parse_single_example
tensorflow2.X版本写法:
features = tf.io.parse_single_example(dataset)
边栏推荐
猜你喜欢
随机推荐
ALIPAY WEB log in rsa encryption analysis record
You know you every day in the use of NAT?
Kubernetes与OpenStack
BSV 上高效的多方公平交易
wps a3格式怎么转换成a4?wps a3格式转换成a4的方法
Go语言并发编程基础上下文概念是什么
The second side of Tencent technical support internship - Tencent's father's luck is so sudden (offer received)
Analysis of WLAN - Wireless Local Area Network
Unity添加程序集引用
Free ARP
wps表格下拉选项怎么添加?wps表格下拉选项的添加方法
Button Wizard Delete File Command
三国战绩物品序号.txt
论文阅读 (66):Explainable Deep Feature Embedding Using Multiple Instance Learning for Pathological Image
wps表格分两页断开怎么办?wps表格分两页断开的解决方法
flutter 书写json解析类
即时聊天系统中群组和好友关系Mysql数据表设计
Adb pull 手机文件到电脑上
我曾七次鄙视自己的灵魂——纪伯伦
应用层协议——RADIUS