验证pixelshuffle函数

1 篇文章 0 订阅

ESPCN中pixelshuffle像素排列


ESPCN中用到了pixelshuffle函数,但为了保险起见,我们还是需要用简单的数来验证下像素点的排列是否与我们想的一致。

以scale=2为例子,采用了像素点全为0.4,0.5,0.6,0.7的size=55四张图片,观察pixelshuffle后1010图片的像素点排列。

import torch
import torch.nn as nn

####################################

#验证pixelshuffle函数是否正常排列像素点。

####################################

a0 = torch.full([1,1,5,5],1)

a1 = torch.full([1,1,5,5],0.4)
print(a1.shape)

a2 = torch.full([1,1,5,5],0.5)
print(a2.shape)

a3 = torch.full([1,1,5,5],0.6)
print(a3.shape)

a4 = torch.full([1,1,5,5],0.7)
print(a4.shape)

in_12 = torch.cat((a1, a2), 1)
in_34 = torch.cat((a3, a4), 1)
input0 = torch.cat((in_12, in_34), 1)
print(input0.shape)

ps = nn.PixelShuffle(2)
out = ps(input0)
print(out.shape)
print(out)

输出结果为
在这里插入图片描述
可以发现,像素点的排列顺序与论文中图示相同。scale>=3的验证方法相同。如果需要按照自己的想法排列像素点,一定要验证输出!!!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值