(self, m)
| 58 | self.spatial_weights = SpatialWeights(dim=dim, reduction=reduction) |
| 59 | |
| 60 | def _init_weights(self, m): |
| 61 | if isinstance(m, nn.Linear): |
| 62 | trunc_normal_(m.weight, std=0.02) |
| 63 | if isinstance(m, nn.Linear) and m.bias is not None: |
| 64 | nn.init.constant_(m.bias, 0) |
| 65 | elif isinstance(m, nn.LayerNorm): |
| 66 | nn.init.constant_(m.bias, 0) |
| 67 | nn.init.constant_(m.weight, 1.0) |
| 68 | elif isinstance(m, nn.Conv2d): |
| 69 | fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels |
| 70 | fan_out //= m.groups |
| 71 | m.weight.data.normal_(0, math.sqrt(2.0 / fan_out)) |
| 72 | if m.bias is not None: |
| 73 | m.bias.data.zero_() |
| 74 | |
| 75 | def forward(self, x1, x2): |
| 76 | channel_weights = self.channel_weights(x1, x2) |
nothing calls this directly
no outgoing calls
no test coverage detected