| 108 | |
| 109 | |
| 110 | class 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 | |
| 131 | class ApertureAwareAttention(nn.Module): |
| 132 |
nothing calls this directly
no outgoing calls
no test coverage detected