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

Method __init__

segmentation/backbones/mit.py:286–363  ·  view source on GitHub ↗
(self,
                 in_channels=3,
                 embed_dims=64,
                 num_stages=4,
                 num_layers=[3, 4, 6, 3],
                 num_heads=[1, 2, 4, 8],
                 patch_sizes=[7, 3, 3, 3],
                 strides=[4, 2, 2, 2],
                 sr_ratios=[8, 4, 2, 1],
                 out_indices=(0, 1, 2, 3),
                 mlp_ratio=4,
                 qkv_bias=True,
                 drop_rate=0.,
                 attn_drop_rate=0.,
                 drop_path_rate=0.,
                 act_cfg=dict(type='GELU'),
                 norm_cfg=dict(type='LN', eps=1e-6),
                 pretrained=None,
                 init_cfg=None)

Source from the content-addressed store, hash-verified

284 """
285
286 def __init__(self,
287 in_channels=3,
288 embed_dims=64,
289 num_stages=4,
290 num_layers=[3, 4, 6, 3],
291 num_heads=[1, 2, 4, 8],
292 patch_sizes=[7, 3, 3, 3],
293 strides=[4, 2, 2, 2],
294 sr_ratios=[8, 4, 2, 1],
295 out_indices=(0, 1, 2, 3),
296 mlp_ratio=4,
297 qkv_bias=True,
298 drop_rate=0.,
299 attn_drop_rate=0.,
300 drop_path_rate=0.,
301 act_cfg=dict(type='GELU'),
302 norm_cfg=dict(type='LN', eps=1e-6),
303 pretrained=None,
304 init_cfg=None):
305 super().__init__()
306
307 if isinstance(pretrained, str) or pretrained is None:
308 warnings.warn('DeprecationWarning: pretrained is a deprecated, '
309 'please use "init_cfg" instead')
310 else:
311 raise TypeError('pretrained must be a str or None')
312
313 self.embed_dims = embed_dims
314
315 self.num_stages = num_stages
316 self.num_layers = num_layers
317 self.num_heads = num_heads
318 self.patch_sizes = patch_sizes
319 self.strides = strides
320 self.sr_ratios = sr_ratios
321 assert num_stages == len(num_layers) == len(num_heads) \
322 == len(patch_sizes) == len(strides) == len(sr_ratios)
323
324 self.out_indices = out_indices
325 assert max(out_indices) < self.num_stages
326 self.pretrained = pretrained
327 self.init_cfg = init_cfg
328
329 # transformer encoder
330 dpr = [
331 x.item()
332 for x in torch.linspace(0, drop_path_rate, sum(num_layers))
333 ] # stochastic num_layer decay rule
334
335 cur = 0
336 self.layers = ModuleList()
337 for i, num_layer in enumerate(num_layers):
338 embed_dims_i = embed_dims * num_heads[i]
339 patch_embed = PatchEmbed(
340 in_channels=in_channels,
341 embed_dims=embed_dims_i,
342 kernel_size=patch_sizes[i],
343 stride=strides[i],

Callers

nothing calls this directly

Calls 3

PatchEmbedClass · 0.50
__init__Method · 0.45

Tested by

no test coverage detected