pytorch forward两个参数实例
以channelAttentionBlock为例子
classCAB(nn.Module): def__init__(self,in_channels,out_channels): super(CAB,self).__init__() self.global_pooling=nn.AdaptiveAvgPool2d(output_size=1) self.conv1=nn.Conv2d(in_channels,out_channels,kernel_size=1,stride=1,padding=0) self.relu=nn.ReLU() self.conv2=nn.Conv2d(out_channels,out_channels,kernel_size=1,stride=1,padding=0) self.sigmod=nn.Sigmoid() defforward(self,x): x1,x2=x#high,low x=torch.cat([x1,x2],dim=1) x=self.global_pooling(x) x=self.conv1(x) x=self.relu(x) x=self.conv2(x) x=self.sigmod(x) x2=x*x2 res=x2+x1 returnres
以上这篇pytorchforward两个参数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。