MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / RSoftmax

Class RSoftmax

segmentation/backbones/resnest.py:16–37  ·  view source on GitHub ↗

Radix Softmax module in ``SplitAttentionConv2d``. Args: radix (int): Radix of input. groups (int): Groups of input.

Source from the content-addressed store, hash-verified

14
15
16class RSoftmax(nn.Module):
17 """Radix Softmax module in ``SplitAttentionConv2d``.
18
19 Args:
20 radix (int): Radix of input.
21 groups (int): Groups of input.
22 """
23
24 def __init__(self, radix, groups):
25 super().__init__()
26 self.radix = radix
27 self.groups = groups
28
29 def forward(self, x):
30 batch = x.size(0)
31 if self.radix > 1:
32 x = x.view(batch, self.groups, self.radix, -1).transpose(1, 2)
33 x = F.softmax(x, dim=1)
34 x = x.reshape(batch, -1)
35 else:
36 x = torch.sigmoid(x)
37 return x
38
39
40class SplitAttentionConv2d(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected