当前位置:网站首页>tensorflow常用的函数
tensorflow常用的函数
2022-04-23 11:22:00 【君子以阅川】
文章目录
tf.nn.conv2d()
tf.nn.conv2d(
input, 输入张量,类型为float16,float32,float64;张量的顺序根据data_format的值来进行解释
filters, 滑动窗口的尺寸,形状为[filter_height, filter_width, in_channels, out_channels],窗口的高,宽,输入的通道数,输出的通道数
strides, 滑动窗口移动的步长[1, strides, strides, 1] 不对batch核channels计算,strides为实际移动步长
padding, 数据填充类型{
'same','valid'}, 前者使用0填充,后者不使用
data_format='NHWC',{
"NHWC", "NCHW"} 分别对应的是N:数据量,H:图像高度,W:图像宽度,C:图像通道数
dilations=None, 可选列表,[1,1,1,1],长度为1-D的张量,input每个维度的扩张系数。如果k>1,则该维度上的每个滤镜元素之间将有k-1个跳过单元格
name=None)
tf.nn.max_pool()
tf.nn.max_pool(
input, 输入张量(Tensor),类型为float16,float32,float64;张量的顺序根据data_format的值来进行解释
ksize, 池化窗口的尺寸,[1, height, width, 1], 不对batch核channels池化,height和width为池化窗口的高度和宽度
strides, 池化窗口移动的步长[1, strides, strides, 1],不对batch核channels计算,strides为实际移动步长
padding, 数据填充类型(string){
'same','valid'}, 前者使用0填充,后者不使用
data_format='NHWC', 'NHWC',图像格式(string){
"NHWC", "NCHW","NCHW_VECT_C"} 分别对应的是N:数据量,H:图像高度,W:图像宽度,C:图像通道数
name=None
)
tf.nn.softmax()
tf.nn.sparse_softmax_cross_entropy_with_logits(
labels,标签张量(Tensor),标签的概率分布,shape为[l0,l1,l2,l3...lr-1],r为标签的分类数,类型为int32或者int64
logits,预测值张量(Tensor),预测的概率分布,shape为[p0,p1,p2,p3...pr-1],其中r是分类数,类型为float16,float32或者float64
name=None
)
Save()
tf.train.Checkpoint().save()
保存ckpt模型
tf.train.Checkpoint(
optimizer=optimizer,
encoder=encoder,
decoder=decoder
).save(file_prefix=("./model/ckpt"))# 可将未训练好的模型保存到modl/ckpt目录下
tf.keras.Model().save()
tf.keras.Model(params).save("./model/h5")
# 例如
model = tf.keras.Model()
model.fit(
inputs,
outputs,
epochs=300,
vebose=1)
mdoel.save(model_path)
tf.keras.models.save_model()
tf.keras.models.save_model(
model, 要保存的 Keras 模型实例
modelpath, 路径(string),要保存的位置
overwrite=True, 我们是应该覆盖目标位置的任何现有模型,还是应该用手动提示来询问用户
include_optimizer=True, 如果为 True,则将优化程序的状态保存在一起
save_formate=None, “tf”或“h5”,指示是将模型保存到 Tensorflow SavedModel 还是 HDF5。在 TF 2.X 中默认为“tf”,在 TF 1.X 中默认为“h5”
signatures=None, 要使用 SavedModel 保存的签名。仅适用于“tf”格式。有关详细信息,请参阅 tf.saved_model.save 中的参数。signatures
options=None (仅适用于已保存模型格式)tf.saved_model。SaveOptions 对象,该对象指定要保存到 SavedModel 的选项
)
Load()
model.load_weight()
导入权重数据和偏置数据
state = tf.train.last_checkpoint(modelpath)
model = tf.keras.Model()
model.load_weights(state)# load权重数据和偏置数据
tf.keras.models.load_model()
导入整个模型包括数据模型和结构模型
model = tf.keras.models.load_model(modelpath)
版权声明
本文为[君子以阅川]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_56104219/article/details/124336639
边栏推荐
- Detailed explanation of how to smoothly go online after MySQL table splitting
- Learning go language 0x02: understanding slice
- Common parameters of ffmpeg command line
- Learning go language 0x08: practice using error in go language journey
- nacos基础(8):登录管理
- CUMCM 2021-B:乙醇偶合制備C4烯烴(2)
- 谁说抠图要会 PS?这个开源神器还能批量抠,效果拔群!
- 学习 Go 语言 0x04:《Go 语言之旅》中切片的练习题代码
- PDMS软光刻加工过程
- Interprocess communication -- message queue
猜你喜欢

redis优化系列(二)Redis主从原理、主从常用配置

laravel编写Console脚本

CUMCM 2021-B:乙醇偶合制備C4烯烴(2)

Database management software sqlpro for SQLite for Mac 2022.30

ConstraintLayout布局

学习 Go 语言 0x04:《Go 语言之旅》中切片的练习题代码

Learn go language 0x04: Code of exercises sliced in go language journey

Cygwin 中的 rename 用法

Mysql8.0安装指南
![Study notes of C [8] SQL [1]](/img/b3/cb684f3ee14cc4e313be217320d5d6.png)
Study notes of C [8] SQL [1]
随机推荐
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
Analysis on the characteristics of the official game economic model launched by platoffarm
map<QString, bool> 的使用记录
Mysql排序的特性详情
Cumcm 2021 - B: préparation d'oléfines C4 par couplage éthanol (2)
Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
Software testers, how to mention bugs?
Mysql8.0安装指南
MIT: label every pixel in the world with unsupervised! Humans: no more 800 hours for an hour of video
Learn go language 0x07: stringer exercise code in go language journey
Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities
CUMCM 2021-B:乙醇偶合制備C4烯烴(2)
qt 64位静态版本显示gif
Mysql中有关Datetime和Timestamp的使用总结
小程序 支付
妊娠箱和分娩箱的区别
分享两个实用的shell脚本
nacos基础(9):nacos配置管理之从单体架构到微服务
PlatoFarm推出正式版游戏经济模型的特点分析
PyTorch 神经网络训练器