首页 > 其他分享 >2023ICLR_SFNet: Selective frequency network for image restoration

2023ICLR_SFNet: Selective frequency network for image restoration

时间:2023-10-23 16:01:13浏览次数:37  
标签:kernel network nn self filter low size image SFNet

1. 在运行SFNet代码时,前后代码保持不变,运行两次结果发生变化, 把下面这段代码注掉就可以保持前后两次运行结果一致,不确定是否是nn.BatchNorm2d计算均值和方差导致

class dynamic_filter(nn.Module):
    def __init__(self, inchannels, mode, kernel_size=3, stride=1, group=8):
        super(dynamic_filter, self).__init__()
        self.stride = stride
        self.kernel_size = kernel_size
        self.group = group

        self.lamb_l = nn.Parameter(torch.zeros(inchannels), requires_grad=True)
        self.lamb_h = nn.Parameter(torch.zeros(inchannels), requires_grad=True)

        self.conv = nn.Conv2d(inchannels, group*kernel_size**2, kernel_size=1, stride=1, bias=False)
        self.bn = nn.BatchNorm2d(group*kernel_size**2)
        self.act = nn.Softmax(dim=-2)
        nn.init.kaiming_normal_(self.conv.weight, mode='fan_out', nonlinearity='relu')

        self.pad = nn.ReflectionPad2d(kernel_size//2)

        self.ap = nn.AdaptiveAvgPool2d((1, 1))
        self.modulate = SFconv(inchannels, mode)

    def forward(self, x):
        identity_input = x 
        low_filter = self.ap(x)
        low_filter = self.conv(low_filter)
        low_filter = self.bn(low_filter)     

        n, c, h, w = x.shape  
        x = F.unfold(self.pad(x), kernel_size=self.kernel_size).reshape(n, self.group, c//self.group, self.kernel_size**2, h*w)

        n,c1,p,q = low_filter.shape
        low_filter = low_filter.reshape(n, c1//self.kernel_size**2, self.kernel_size**2, p*q).unsqueeze(2)
       
        low_filter = self.act(low_filter)
    
        low_part = torch.sum(x * low_filter, dim=3).reshape(n, c, h, w)

        out_high = identity_input - low_part
        out = self.modulate(low_part, out_high)
        return out

 

标签:kernel,network,nn,self,filter,low,size,image,SFNet
From: https://www.cnblogs.com/yyhappy/p/17782669.html

相关文章

  • 关于 linux uimage 的理解
    网上的资料:      ......
  • 安装Image Color Summarizer
    安装网页网址: http://mkweb.bcgsc.ca/color-summarizer/?download在网址栏输入URL: http://mkweb.bcgsc.ca/color-summarizer/download/colorsummarizer-0.80-win.zip下载后如图 在搜索栏输入cmd调出命令管理器输入命令  -help会得到用法帮助bin\colorsummarize......
  • Matching Network算法概述
    什么是MatchingNetwork1.论文地址:MatchingNetworksforOneShotLearning2.简介:基于MetricLearning部分思想,使用外部记忆来增强网络,提高网络的学习能力。3.创新点借鉴了注意力和外部记忆方面的经验来搭建网络基于meta-learning用task来训练,而不是metric-learning输入......
  • Conditional Probability Models for Deep Image Compression
    深度神经网络被训练来作为图像压缩的自动编码器是一个前沿方向,面临的挑战有两方面——量化(quantization)和权衡reconstructionerror(distortion)andentropy(rate),这篇文章关注后者。主要思想是使用上下文模型直接对潜在表示的熵建模;3D-CNN一个学习自动编码器潜在分布的条......
  • Linux (7) NetworkManager重置resolve.conf
    《WindowsAzurePlatform系列文章目录》 在默认情况下,AzureLinuxVM会安装waagent,而waagent会依赖于NetworkManager服务。当我们修改了resolve.conf的时候,如果重启NetworkManager或者重启了LinuxVM,NetworkManager会重置resolve.conf。 目前有两个......
  • Networkx 常用
    networkstatisticsprint('*'*30)print('networkstatistics')print(nx.info(G))print(nx.is_connected(G))components=nx.connected_components(G)print('numofconnected_components:',nx.number_connected_components(G))tri......
  • 【论文阅读】DeepAR Probabilistic forecasting with autoregressive recurrent netwo
    原始题目:DeepAR:Probabilisticforecastingwithautoregressiverecurrentnetworks中文翻译:DeepAR:自回归递归网络的概率预测发表时间:2020年07月平台:InternationalJournalofForecasting文章链接:https://www.sciencedirect.com/science/article/pii/S0169207019301888......
  • Image中的transformation理解【swt.snippet】
    /********************************************************************************Copyright(c)2000,2005IBMCorporationandothers.*Allrightsreserved.Thisprogramandtheaccompanyingmaterials*aremadeavailableunderthetermsoftheEclip......
  • 论文阅读:A_Multi-Granularity_Scene_Segmentation_Network_for_Human-Robot_Collabora
    A_Multi-Granularity_Scene_Segmentation_Network_for_Human-Robot_Collaboration_Environment_Perception用于人与机器人协作环境感知的多颗粒度场景分割网络摘要人机协作(Human-robotcollaboration,HRC)被认为是未来以人为中心的智能制造的一种有前途的范式,以满足蓬勃发展的大......
  • Conditional Probability Models for Deep Image Compression
    深度神经网络被训练来作为图像压缩的自动编码器是一个前沿方向,面临的挑战有两方面——量化(quantization)和权衡reconstructionerror(distortion)andentropy(rate),这篇文章关注后者。主要思想是使用上下文模型直接对潜在表示的熵建模;3D-CNN一个学习自动编码器潜在分布的条......