• 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
  • 相关阅读:
    python每日活力练习Day29
    python活力练习Day28
    python活力练习Day27
    pyhton 活力练习Day26
    排序算法之归并排序
    排序算法之快速排序
    Python 多线程
    排序算法之希尔排序
    排序算法之插入排序
    ELK(elasticsearch+kibana+logstash)搜索引擎(一): 环境搭建
  • 原文地址:https://www.cnblogs.com/haiboxiaobai/p/13029920.html
Copyright © 2020-2023  润新知