当前位置:网站首页>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
边栏推荐
- C# EF mysql更新datetime字段报错Modifying a column with the ‘Identity‘ pattern is not supported
- 第5 章 机器学习基础
- What did you do during the internship
- Summary of image classification white box anti attack technology
- PyTorch训练一个网络的基本流程5步法
- [Point Cloud Series] SG - Gan: Adversarial Self - attachment GCN for Point Cloud Topological parts Generation
- Project, how to package
- 【动态规划】最长递增子序列
- Fill the network gap
- 【点云系列】SO-Net:Self-Organizing Network for Point Cloud Analysis
猜你喜欢

C# EF mysql更新datetime字段报错Modifying a column with the ‘Identity‘ pattern is not supported

【指标】Precision、Recall

【点云系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation

Gee configuring local development environment

第2章 Pytorch基础1

第2章 Pytorch基础2

MySQL数据库安装与配置详解

【3D形状重建系列】Implicit Functions in Feature Space for 3D Shape Reconstruction and Completion

Visual studio 2019 installation and use

Record WebView shows another empty pit
随机推荐
Pymysql connection database
免费使用OriginPro学习版
Summary of image classification white box anti attack technology
[recommendation for new books in 2021] professional azure SQL managed database administration
【点云系列】 场景识别类导读
Reading notes - activity
Computer shutdown program
PyTorch最佳实践和代码编写风格指南
Pytorch model pruning example tutorial III. multi parameter and global pruning
Pytorch模型保存与加载(示例)
PyTorch 10. 学习率
MySQL的安装与配置——详细教程
Component based learning (3) path and group annotations in arouter
Face_ Recognition face detection
Common regular expressions
【期刊会议系列】IEEE系列模板下载指南
第4章 Pytorch数据处理工具箱
【动态规划】三角形最小路径和
Project, how to package
C language, a number guessing game