MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / MSA_head

Class MSA_head

lib/VIT/decoder/decoder_p.py:155–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153 weight_init(self)
154
155class MSA_head(nn.Module):
156 def __init__(self, mode='dilation',dim=128, num_heads=8, ffn_expansion_factor=4, bias=False, LayerNorm_type='WithBias'):
157 super(MSA_head, self).__init__()
158 self.norm1 = LayerNorm(dim, LayerNorm_type)
159 self.attn = Attention(dim, num_heads, bias,mode)
160 self.norm2 = LayerNorm(dim, LayerNorm_type)
161 self.ffn = FeedForward(dim, ffn_expansion_factor, bias)
162
163 def forward(self, x,mask=None):
164 x = x + self.attn(self.norm1(x),mask)
165 x = x + self.ffn(self.norm2(x))
166 return x
167
168 def initialize(self):
169 weight_init(self)
170
171class MSA_module(nn.Module):
172 def __init__(self, dim=128):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected