MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / __init__

Method __init__

timm/models/layers/selective_kernel.py:22–34  ·  view source on GitHub ↗

Selective Kernel Attention Module Selective Kernel attention mechanism factored out into its own module.

(self, channels, num_paths=2, attn_channels=32,
                 act_layer=nn.ReLU, norm_layer=nn.BatchNorm2d)

Source from the content-addressed store, hash-verified

20
21class SelectiveKernelAttn(nn.Module):
22 def __init__(self, channels, num_paths=2, attn_channels=32,
23 act_layer=nn.ReLU, norm_layer=nn.BatchNorm2d):
24 """ Selective Kernel Attention Module
25
26 Selective Kernel attention mechanism factored out into its own module.
27
28 """
29 super(SelectiveKernelAttn, self).__init__()
30 self.num_paths = num_paths
31 self.fc_reduce = nn.Conv2d(channels, attn_channels, kernel_size=1, bias=False)
32 self.bn = norm_layer(attn_channels)
33 self.act = act_layer(inplace=True)
34 self.fc_select = nn.Conv2d(attn_channels, channels * num_paths, kernel_size=1, bias=False)
35
36 def forward(self, x):
37 assert x.shape[1] == self.num_paths

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected