MCPcopy Create free account
hub / github.com/PolyU-ChenLab/UniPixel / __init__

Method __init__

sam2/modeling/memory_encoder.py:73–99  ·  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

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