当前位置:网站首页>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 命令行 连接 yarn
LC501. Mode in binary search tree
从零开始学 MySQL —数据库和数据表操作
2020-ViT ICLR
[jetcache] how to use jetcache
Origin2018安装教程「建议收藏」
聊一聊Zabbix都监控哪些参数
园区全光技术选型-中篇
隐藏用户的创建和使用
Mysql——》MyISAM存储引擎的索引
MySQL stored procedure
Learning notes on futuretask source code of concurrent programming series
Slope compensation
QT版本华睿相机的Demo程序实现
Friendly serial assistant tutorial_ How to configure friendly serial port debugging assistant - tutorial on using friendly serial port debugging assistant
Pytorch's code for visualizing feature maps after training its own network
【图像分割】2021-SegFormer NeurIPS
keras训练的H5模型转tflite









