MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / __init__

Method __init__

sam2_train/modeling/memory_encoder.py:74–102  ·  view source on GitHub ↗
(
        self,
        dim,
        kernel_size=7,
        padding=3,
        drop_path=0.0,
        layer_scale_init_value=1e-6,
        use_dwconv=True,
    )

Source from the content-addressed store, hash-verified

72 """
73
74 def __init__(
75 self,
76 dim,
77 kernel_size=7,
78 padding=3,
79 drop_path=0.0,
80 layer_scale_init_value=1e-6,
81 use_dwconv=True,
82 ):
83 super().__init__()
84 self.dwconv = nn.Conv2d(
85 dim,
86 dim,
87 kernel_size=kernel_size,
88 padding=padding,
89 groups=dim if use_dwconv else 1,
90 ) # depthwise conv
91 self.norm = LayerNorm2d(dim, eps=1e-6)
92 self.pwconv1 = nn.Linear(
93 dim, 4 * dim
94 ) # pointwise/1x1 convs, implemented with linear layers
95 self.act = nn.GELU()
96 self.pwconv2 = nn.Linear(4 * dim, dim)
97 self.gamma = (
98 nn.Parameter(layer_scale_init_value * torch.ones((dim)), requires_grad=True)
99 if layer_scale_init_value > 0
100 else None
101 )
102 self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
103
104 def forward(self, x):
105 input = x

Callers

nothing calls this directly

Calls 3

LayerNorm2dClass · 0.90
DropPathClass · 0.90
__init__Method · 0.45

Tested by

no test coverage detected