Restore conv7x7 in MONA (full 3x3+5x5+7x7 multi-scale)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
pikaliov
2026-04-21 21:45:27 +03:00
parent 11fc348ecd
commit 471bc6444a

View File

@@ -29,17 +29,18 @@ coloredlogs.install(level="INFO", logger=LOGGER, fmt="%(asctime)s %(name)s %(lev
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
class MonaOp(nn.Module): class MonaOp(nn.Module):
"""Multi-cognitive visual filter: parallel depthwise convs (3×3, 5×5).""" """Multi-cognitive visual filter: parallel depthwise convs (3×3, 5×5, 7×7)."""
def __init__(self, channels: int) -> None: def __init__(self, channels: int) -> None:
super().__init__() super().__init__()
self.conv3 = nn.Conv2d(channels, channels, kernel_size=3, padding=1, groups=channels) self.conv3 = nn.Conv2d(channels, channels, kernel_size=3, padding=1, groups=channels)
self.conv5 = nn.Conv2d(channels, channels, kernel_size=5, padding=2, groups=channels) self.conv5 = nn.Conv2d(channels, channels, kernel_size=5, padding=2, groups=channels)
self.conv7 = nn.Conv2d(channels, channels, kernel_size=7, padding=3, groups=channels)
self.projector = nn.Conv2d(channels, channels, kernel_size=1) self.projector = nn.Conv2d(channels, channels, kernel_size=1)
def forward(self, x: torch.Tensor) -> torch.Tensor: def forward(self, x: torch.Tensor) -> torch.Tensor:
identity = x identity = x
x = (self.conv3(x) + self.conv5(x)) / 2.0 + identity x = (self.conv3(x) + self.conv5(x) + self.conv7(x)) / 3.0 + identity
return x + self.projector(x) return x + self.projector(x)