diff --git a/torchvision/ops/feature_pyramid_network.py b/torchvision/ops/feature_pyramid_network.py index f4b190844ff..2e7aef0e2fa 100644 --- a/torchvision/ops/feature_pyramid_network.py +++ b/torchvision/ops/feature_pyramid_network.py @@ -206,7 +206,7 @@ def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]: class LastLevelMaxPool(ExtraFPNBlock): """ - Applies a max_pool2d on top of the last feature map + Applies a max_pool2d (not actual max_pool2d, we just subsample) on top of the last feature map """ def forward( @@ -216,7 +216,8 @@ def forward( names: List[str], ) -> Tuple[List[Tensor], List[str]]: names.append("pool") - x.append(F.max_pool2d(x[-1], 1, 2, 0)) + # Use max pooling to simulate stride 2 subsampling + x.append(F.max_pool2d(x[-1], kernel_size=1, stride=2, padding=0)) return x, names