zoukankan      html  css  js  c++  java
  • ASPP pytorch 实现

    class ASPP(nn.Module):
        def __init__(self, in_channel=512, depth=256):
            super(ASPP,self).__init__()
            # global average pooling : init nn.AdaptiveAvgPool2d ;also forward torch.mean(,,keep_dim=True)
            self.mean = nn.AdaptiveAvgPool2d((1, 1))
            self.conv = nn.Conv2d(in_channel, depth, 1, 1)
            # k=1 s=1 no pad
            self.atrous_block1 = nn.Conv2d(in_channel, depth, 1, 1)
            self.atrous_block6 = nn.Conv2d(in_channel, depth, 3, 1, padding=6, dilation=6)
            self.atrous_block12 = nn.Conv2d(in_channel, depth, 3, 1, padding=12, dilation=12)
            self.atrous_block18 = nn.Conv2d(in_channel, depth, 3, 1, padding=18, dilation=18)
     
            self.conv_1x1_output = nn.Conv2d(depth * 5, depth, 1, 1)
     
        def forward(self, x):
            size = x.shape[2:]
     
            image_features = self.mean(x)
            image_features = self.conv(image_features)
            image_features = F.upsample(image_features, size=size, mode='bilinear')
     
            atrous_block1 = self.atrous_block1(x)
     
            atrous_block6 = self.atrous_block6(x)
     
            atrous_block12 = self.atrous_block12(x)
     
            atrous_block18 = self.atrous_block18(x)
     
            net = self.conv_1x1_output(torch.cat([image_features, atrous_block1, atrous_block6,
                                                  atrous_block12, atrous_block18], dim=1))
            return net
  • 相关阅读:
    uart协议--Verilog及仿真
    DC综合的流程
    modelsim将vcd文件转换成wlf文件并查看波形
    将系统盘还原成原来的普通u盘
    Ubuntu的操作命令
    gvim快捷键
    dc_shell环境下TCL语言的使用
    AHB总线学习
    Ubuntu文件共享
    Linux基础学习 | 目录及文件
  • 原文地址:https://www.cnblogs.com/haiboxiaobai/p/13029920.html
Copyright © 2011-2022 走看看