当前位置:网站首页>F.pad 的妙用
F.pad 的妙用
2022-04-23 06:12:00 【wujpbb7】
F.pad 的使用参考 Pytorch之torch.nn.functional.pad函数详解 。
F.pad 可用在通道扩充上,在动态batch输入时,导出的onnx非常简洁。
# 简化的示例代码
import torch
import torch.nn.functional as F
x = torch.randn(1,3,5,4)
added_chan_num = 2
use_pad = True
if (not use_pad):
z = torch.zeros(1,added_chan_num,5,4)
x_a = torch.cat((x,z),dim=1)
else:
x_a = F.pad(x, (0,0,0,0,0,added_chan_num), 'constant', 0)
print(x_a)
onnx效果:
版权声明
本文为[wujpbb7]所创,转载请带上原文链接,感谢
https://blog.csdn.net/blueblood7/article/details/121013787
边栏推荐
- “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
- ArcGIS license server administrator cannot start the workaround
- How to standardize multidimensional matrix (based on numpy)
- [3D shape reconstruction series] implicit functions in feature space for 3D shape reconstruction and completion
- Chapter 1 numpy Foundation
- 第4章 Pytorch数据处理工具箱
- PaddleOCR 图片文字提取
- Write a wechat double open gadget to your girlfriend
- Chapter 2 pytoch foundation 2
- PyMySQL连接数据库
猜你喜欢
winform滚动条美化
MySQL installation and configuration - detailed tutorial
机器学习——PCA与LDA
ArcGIS License Server Administrator 无法启动解决方法
GEE配置本地开发环境
c语言编写一个猜数字游戏编写
【点云系列】 A Rotation-Invariant Framework for Deep Point Cloud Analysis
[point cloud series] pnp-3d: a plug and play for 3D point clouds
Use originpro express for free
【点云系列】Learning Representations and Generative Models for 3D pointclouds
随机推荐
Gephi教程【1】安装
PyTorch 11.正则化
第2章 Pytorch基础1
WinForm scroll bar beautification
torch.mm() torch.sparse.mm() torch.bmm() torch.mul() torch.matmul()的区别
【点云系列】 场景识别类导读
第4章 Pytorch数据处理工具箱
Android exposed components - ignored component security
Visual Studio 2019安装与使用
[2021 book recommendation] practical node red programming
“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
Common regular expressions
Chapter 8 generative deep learning
Keras如何保存、加载Keras模型
PyTorch 模型剪枝实例教程三、多参数与全局剪枝
红外传感器控制开关
机器学习 三: 基于逻辑回归的分类预测
Use originpro express for free
[2021 book recommendation] learn winui 3.0
C# EF mysql更新datetime字段报错Modifying a column with the ‘Identity‘ pattern is not supported