MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / forward

Method forward

selfpatch_vision_transformer.py:187–194  ·  view source on GitHub ↗
(self, x_cls, x, return_attention=False)

Source from the content-addressed store, hash-verified

185 self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
186
187 def forward(self, x_cls, x, return_attention=False):
188 u = torch.cat((x_cls,x),dim=1)
189 y, attn = self.attn(self.norm1(u))
190 if return_attention:
191 return attn
192 x = x + self.drop_path(y)
193 x = x + self.drop_path(self.mlp(self.norm2(x)))
194 return x
195
196class Attention(nn.Module):
197 def __init__(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0.):

Callers

nothing calls this directly

Calls 2

norm1Method · 0.45
norm2Method · 0.45

Tested by

no test coverage detected