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)
| 747 | } |
| 748 | |
| 749 | def forward(self, x): |
| 750 | """ |
| 751 | Args: |
| 752 | x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``. |
| 753 | Returns: |
| 754 | dict[str->Tensor]: names and the corresponding features |
| 755 | """ |
| 756 | assert ( |
| 757 | x.dim() == 4 |
| 758 | ), f"SwinTransformer takes an input of shape (N, C, H, W). Got {x.shape} instead!" |
| 759 | outputs = {} |
| 760 | y = super().forward(x) |
| 761 | for k in y.keys(): |
| 762 | if k in self._out_features: |
| 763 | outputs[k] = y[k] |
| 764 | return outputs |
| 765 | |
| 766 | def output_shape(self): |
| 767 | return { |