(self, dilation_series=[6, 12, 18], padding_series=[6, 12, 18], depth=128)
| 103 | # 目前太肥了,这玩意儿输出一个12*12的图片,需要2048的channel? |
| 104 | class GPM(nn.Module): |
| 105 | def __init__(self, dilation_series=[6, 12, 18], padding_series=[6, 12, 18], depth=128): |
| 106 | # def __init__(self, dilation_series=[2, 5, 7], padding_series=[2, 5, 7], depth=128): |
| 107 | super(GPM, self).__init__() |
| 108 | self.branch_main = nn.Sequential( |
| 109 | nn.AdaptiveAvgPool2d((1, 1)), |
| 110 | BasicConv2d(2048, depth, kernel_size=1, stride=1) |
| 111 | ) |
| 112 | self.branch0 = BasicConv2d(2048, depth, kernel_size=1, stride=1) |
| 113 | self.branch1 = BasicConv2d(2048, depth, kernel_size=3, stride=1, padding=padding_series[0], |
| 114 | dilation=dilation_series[0]) |
| 115 | self.branch2 = BasicConv2d(2048, depth, kernel_size=3, stride=1, padding=padding_series[1], |
| 116 | dilation=dilation_series[1]) |
| 117 | self.branch3 = BasicConv2d(2048, depth, kernel_size=3, stride=1, padding=padding_series[2], |
| 118 | dilation=dilation_series[2]) |
| 119 | self.head = nn.Sequential( |
| 120 | BasicConv2d(depth * 5, 256, kernel_size=3, padding=1), |
| 121 | PAM(256) |
| 122 | ) |
| 123 | self.out = nn.Sequential( |
| 124 | nn.Conv2d(256, 64, 3, padding=1), |
| 125 | nn.BatchNorm2d(64, affine=affine_par), |
| 126 | nn.PReLU(), |
| 127 | nn.Dropout2d(p=0.1), |
| 128 | nn.Conv2d(64, 1, 1) |
| 129 | ) |
| 130 | |
| 131 | for m in self.modules(): |
| 132 | if isinstance(m, nn.Conv2d): |
| 133 | n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels |
| 134 | m.weight.data.normal_(0, 0.01) |
| 135 | elif isinstance(m, nn.BatchNorm2d): |
| 136 | m.weight.data.fill_(1) |
| 137 | m.bias.data.zero_() |
| 138 | |
| 139 | def forward(self, x): |
| 140 | # out = self.conv2d_list[0](x) |
nothing calls this directly
no test coverage detected