MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / __init__

Method __init__

timm/models/layers/patch_embed.py:18–29  ·  view source on GitHub ↗
(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768, norm_layer=None, flatten=True)

Source from the content-addressed store, hash-verified

16 """ 2D Image to Patch Embedding
17 """
18 def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768, norm_layer=None, flatten=True):
19 super().__init__()
20 img_size = to_2tuple(img_size)
21 patch_size = to_2tuple(patch_size)
22 self.img_size = img_size
23 self.patch_size = patch_size
24 self.grid_size = (img_size[0] // patch_size[0], img_size[1] // patch_size[1])
25 self.num_patches = self.grid_size[0] * self.grid_size[1]
26 self.flatten = flatten
27
28 self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
29 self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()
30
31 def forward(self, x):
32 B, C, H, W = x.shape

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected