Bootstrap

Pytorch 实现GlobalContextBlock,Pythonstudio基础教程

nn.LayerNorm([self.planes, 1, 1]),

nn.ReLU(inplace=True), # yapf: disable

nn.Conv2d(self.planes, self.inplanes, kernel_size=1))

else:

self.channel_add_conv = None

if ‘channel_mul’ in fusion_types:

self.channel_mul_conv = nn.Sequential(

nn.Conv2d(self.inplanes, self.planes, kernel_size=1),

nn.LayerNorm([self.planes, 1, 1]),

nn.ReLU(inplace=True), # yapf: disable

nn.Conv2d(self.planes, self.inplanes, kernel_size=1))

else:

self.channel_mul_conv = None

def spatial_pool(self, x):

batch, channel, height, width = x.size()

if self.pooling_type == ‘att’:

input_x = x

[N, C, H * W]

input_x = input_x.view(batch, channel, height * width)

[N, 1, C, H * W]

input_x = input_x.unsqueeze(1)

[N, 1, H, W]</

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;