当前位置:网站首页>从tf 1.x到tf 2.6(遇到的就过来更新更新)
从tf 1.x到tf 2.6(遇到的就过来更新更新)
2022-06-26 09:34:00 【天边一坨浮云】
我用的是tensorflow 2.6
一般来说在tf 2.x中都可以使用tf.compat.v1.xxxxxx来替代原来tf 1.x中的tf.xxxxxx
如果报错,说函数没有,其实可以直接去github的tensorflow项目里搜索这个函数,看tensorflow里是怎么用的
这里列一列遇到的
tf 1.x:tf.contrib.layers.xavier_initializer
tf 2.6:tf.keras.initializers.glorot_normal
tf 1.x:tf.contrib.layers
tf 2.6:tf.keras.layers
tf 1.x:from tensorflow.contrib import tpu
tf 2.6:from tensorflow import tpu
tf 1.x:from tensorflow.contrib import data
tf 2.6:from tensorflow import data
tf 1.x:from tensorflow.contrib import metrics
tf 2.6:from tensorflow import metrics
tf 1.x: from tensorflow.contrib import cluster_resolver
tf 2.6: from tensorflow.python.distribute import cluster_resolver
tf 1.x: tf.contrib.layers.layer_norm
tf 2.6: tf.keras.layers.LayerNormalization
这两个函数实现不同,不能只是换个名字
Keras 2.2.5:from keras.optimizers import Adam
Keras 2.6.0:from keras.optimizer_v2.adam import Adam
Keras 2.2.5:from keras.utils import to_categorical
Keras 2.6.0:from keras.utils.np_utils import to_categorical
RuntimeError: When eager execution is enabled, var_list must specify a list or dict of variables to save
当eager execution开启的时候,loss应该是一个Python函数。
在Tensorflow 2.0 中,eager execution 是默认开启的。
所以,需要先关闭eager execution
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
边栏推荐
- 安装 新版本cmake & swig & tinyspline
- LeetCode 498. 对角线遍历
- [trajectory planning] testing of ruckig Library
- Opencv depthframe - > pointcloud causes segmentation fault!
- 做测试需要知道的内容——url、弱网、接口、自动化、
- thinkphp6.0的第三方扩展包,支持上传阿里云,七牛云
- 2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(1)详细解析教程
- LeetCode 498. Diagonal traversal
- Redis notes (12) - single thread architecture (non blocking IO, multiplexing) and multiple asynchronous threads
- logback
猜你喜欢

The 100000 line transaction lock has opened your eyes.

Record a time when the server was taken to mine

测试须知——常见接口协议解析

3 big questions! Redis cache exceptions and handling scheme summary

Detailed explanation of the network security competition questions (2) of the 2021 national vocational college skills competition (secondary vocational group)

jz2440---使用uboot烧录程序

Comprehensive interpretation! Use of generics in golang
![[trajectory planning] testing of ruckig Library](/img/c7/51c0f6dc3bf7c7fa4528118a4c32fa.png)
[trajectory planning] testing of ruckig Library

Curriculum learning (CL)

欧冠比赛数据集(梅西不哭-离开巴萨也可能再创巅峰)
随机推荐
Specific implementation comparison between different programming languages
力扣------从数组中移除最大值和最小值
Do you know the //go: instructions in the go source code, go:linkname?
Jupyter Notebook遇到的问题
Explained: A Style-Based Generator Architecture for GANs (StyleGAN)
Several connection query methods of SQL (internal connection, external connection, full connection and joint query)
OpenCV depthframe -> pointcloud 导致 segmentation fault!
Champions League data set (Messi doesn't cry - leaving Barcelona may reach another peak)
#云原生征文# 在 Google Kubernetes Cluster 上使用 HANA Expression Database Service
软件测试---如何选择合适的正交表
Origin of QPM
自动化测试——关于unitest与pytest初始化共存问题
Throttling, anti chattering, new function, coriolism
LeetCode 接雨水系列 42.(一维) 407.(二维)
LeetCode 剑指 Offer II 091.粉刷房子 - 原地修改
Comparison of similar PMS in QPM
The first problem troubleshooting process of re disk
GAN Inversion: A Survey
pcl install
Leetcode refers to offer II 091 Paint house - modify in place