当前位置: 移动技术网 > IT编程>脚本编程>Python > pytorch forward两个参数实例

pytorch forward两个参数实例

2020年03月09日  | 移动技术网IT编程  | 我要评论

恶俗穿越之失宠王妃,丰田汽车召回事件,罗百辉

以channel attention block为例子

class cab(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()
 
  def forward(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
    return res

以上这篇pytorch forward两个参数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网