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

Method __init__

detection/backbone/vit_SelfPatch.py:69–78  ·  view source on GitHub ↗
(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0.)

Source from the content-addressed store, hash-verified

67
68class Attention(nn.Module):
69 def __init__(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0.):
70 super().__init__()
71 self.num_heads = num_heads
72 head_dim = dim // num_heads
73 self.scale = qk_scale or head_dim ** -0.5
74
75 self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
76 self.attn_drop = nn.Dropout(attn_drop)
77 self.proj = nn.Linear(dim, dim)
78 self.proj_drop = nn.Dropout(proj_drop)
79
80 def forward(self, x):
81 B, N, C = x.shape

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected