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)
| 808 | } |
| 809 | |
| 810 | def forward(self, x): |
| 811 | """ |
| 812 | Args: |
| 813 | x: Tensor of shape (N,C,H,W). H, W must be a multiple of ``self.size_divisibility``. |
| 814 | Returns: |
| 815 | dict[str->Tensor]: names and the corresponding features |
| 816 | """ |
| 817 | assert ( |
| 818 | x.dim() == 4 |
| 819 | ), f"SwinTransformer takes an input of shape (N, C, H, W). Got {x.shape} instead!" |
| 820 | outputs = {} |
| 821 | y = super().forward(x) |
| 822 | for k in y.keys(): |
| 823 | if k in self._out_features: |
| 824 | outputs[k] = y[k] |
| 825 | return outputs |
| 826 | |
| 827 | def output_shape(self): |
| 828 | feature_names = list(set(self._out_feature_strides.keys()) & set(self._out_features)) |