当前位置:网站首页>Pytorch nn. functional. Simple understanding and usage of unfold()
Pytorch nn. functional. Simple understanding and usage of unfold()
2022-07-01 22:47:00 【zouxiaolv】
import torch
from torch.nn import functional as F
x =torch.arange(36).view(1,2,2,9).float()
print('x',x)
x = F.unfold(x, (2, 2))
print('x1',x)
print(x.size())x tensor([[[[ 0., 1., 2., 3., 4., 5., 6., 7., 8.],
[ 9., 10., 11., 12., 13., 14., 15., 16., 17.]],
[[18., 19., 20., 21., 22., 23., 24., 25., 26.],
[27., 28., 29., 30., 31., 32., 33., 34., 35.]]]])
x1 tensor([[[ 0., 1., 2., 3., 4., 5., 6., 7.],
[ 1., 2., 3., 4., 5., 6., 7., 8.],
[ 9., 10., 11., 12., 13., 14., 15., 16.],
[10., 11., 12., 13., 14., 15., 16., 17.],
[18., 19., 20., 21., 22., 23., 24., 25.],
[19., 20., 21., 22., 23., 24., 25., 26.],
[27., 28., 29., 30., 31., 32., 33., 34.],
[28., 29., 30., 31., 32., 33., 34., 35.]]])
torch.Size([1, 8, 8])The sliding window is 2*2
Then the range of sliding input is 2*2, For example, the first one is
[0., 1.,
9., 10.]The output is flattened into
[0.,
1.,
9.,
10.]In turn, it becomes the above output form
边栏推荐
猜你喜欢
随机推荐
【无标题】
flink sql-client 使用 对照并熟悉官方文档
Relationship and difference between enterprise architecture and project management
切面条 C语言
Rust语言——小小白的入门学习05
Appium automated testing foundation - Supplement: introduction to desired capabilities parameters
阿洛迷茫后的思考
倒置残差的理解
Basic knowledge of ngnix
The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner
SAP UI5 应用开发教程之一百零四 - SAP UI5 表格控件的支持复选(Multi-Select)以及如何用代码一次选中多个表格行项目
配置筛选机
并发编程系列之FutureTask源码学习笔记
C#/VB. Net to add text / image watermarks to PDF documents
MySQL之MHA高可用配置及故障切换
Mysql——》MyISAM存储引擎的索引
General use of qstringlist
多图预警~ 华为 ECS 与 阿里云 ECS 对比实战
mixconv代码
详解Kubernetes网络模型









