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

Method __init__

method/nn_util.py:111–125  ·  view source on GitHub ↗

:param num_channel: Number of channels in the input tensor :param apply_att_weights: Should attention weights be applied in the forward pass?

(self, num_channel, apply_att_weights=False)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 3

ApplyVectorWeightsClass · 0.85
IdentityModClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected