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

Method forward

models/swin_transformer.py:448–456  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

446 self.norm = None
447
448 def forward(self, x):
449 B, C, H, W = x.shape
450 # FIXME look at relaxing size constraints
451 assert H == self.img_size[0] and W == self.img_size[1], \
452 f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})."
453 x = self.proj(x).flatten(2).transpose(1, 2) # B Ph*Pw C
454 if self.norm is not None:
455 x = self.norm(x)
456 return x
457
458 def flops(self):
459 Ho, Wo = self.patches_resolution

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected