MCPcopy Create free account
hub / github.com/TimSeizinger/Bokehlicious / SimplifiedChannelAttention

Class SimplifiedChannelAttention

method/nn_util.py:110–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109
110class SimplifiedChannelAttention(nn.Module):
111 def __init__(self, num_channel, apply_att_weights=False):
112 """
113
114 :param num_channel: Number of channels in the input tensor
115 :param apply_att_weights: Should attention weights be applied in the forward pass?
116 """
117 super(SimplifiedChannelAttention, self).__init__()
118
119 self.model = nn.Sequential(
120 nn.AdaptiveAvgPool2d(1),
121 nn.Conv2d(in_channels=num_channel, out_channels=num_channel, kernel_size=1, padding=0, stride=1,
122 groups=1, bias=True),
123 )
124
125 self.apply1 = ApplyVectorWeights() if apply_att_weights else IdentityMod()
126
127 def forward(self, x: Tensor, att_weights: Tensor = None) -> Tensor:
128 x = self.model(x)
129 return self.apply1(x=x, weights=att_weights)
130
131class ApertureAwareAttention(nn.Module):
132

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected