MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / __init__

Method __init__

mmseg/models/backbones/scnet.py:79–98  ·  view source on GitHub ↗
(self, dim, num_head=8, window=7, norm_cfg=dict(type="SyncBN", requires_grad=True))

Source from the content-addressed store, hash-verified

77
78class MemoryModule(nn.Module):
79 def __init__(self, dim, num_head=8, window=7, norm_cfg=dict(type="SyncBN", requires_grad=True)):
80 super().__init__()
81 self.num_head = num_head
82 self.window = window
83
84 self.q = nn.Linear(dim, dim)
85 self.a = nn.Linear(dim, dim)
86 self.l = nn.Linear(dim, dim)
87 self.conv = nn.Conv2d(dim, dim, 7, padding=3, groups=dim)
88
89 self.proj = nn.Linear(dim, dim)
90 if window != 0:
91 # self.t = nn.Linear(dim, window*window*num_head)
92 self.conv_att = nn.Conv2d(dim, dim, 7, padding=3, groups=dim)
93 self.kv = nn.Linear(dim, dim * 2)
94 self.m = nn.Parameter(torch.zeros(1, window, window, dim), requires_grad=True)
95 self.proj = nn.Linear(dim * 2, dim)
96
97 self.act = nn.GELU()
98 self.norm = LayerNorm(dim, eps=1e-6, data_format="channels_last")
99
100 def forward(self, x):
101 B, H, W, C = x.size()

Callers

nothing calls this directly

Calls 2

LayerNormClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected