Args: x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``. Returns: dict[str->Tensor]: names and the corresponding features
(self, x)
| 650 | } |
| 651 | |
| 652 | def forward(self, x): |
| 653 | """ |
| 654 | Args: |
| 655 | x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``. |
| 656 | Returns: |
| 657 | dict[str->Tensor]: names and the corresponding features |
| 658 | """ |
| 659 | assert ( |
| 660 | x.dim() == 4 |
| 661 | ), f"SwinTransformer takes an input of shape (N, C, H, W). Got {x.shape} instead!" |
| 662 | outputs = {} |
| 663 | y = super().forward(x) |
| 664 | for k in y.keys(): |
| 665 | if k in self._out_features: |
| 666 | outputs[k] = y[k] |
| 667 | return outputs |
| 668 | |
| 669 | def output_shape(self): |
| 670 | return { |