MCPcopy Create free account
hub / github.com/SwinTransformer/Transformer-SSL / __init__

Method __init__

models/swin_transformer.py:429–446  ·  view source on GitHub ↗
(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None)

Source from the content-addressed store, hash-verified

427 """
428
429 def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):
430 super().__init__()
431 img_size = to_2tuple(img_size)
432 patch_size = to_2tuple(patch_size)
433 patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]]
434 self.img_size = img_size
435 self.patch_size = patch_size
436 self.patches_resolution = patches_resolution
437 self.num_patches = patches_resolution[0] * patches_resolution[1]
438
439 self.in_chans = in_chans
440 self.embed_dim = embed_dim
441
442 self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
443 if norm_layer is not None:
444 self.norm = norm_layer(embed_dim)
445 else:
446 self.norm = None
447
448 def forward(self, x):
449 B, C, H, W = x.shape

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected