Skip to content

Commit abc40ef

Browse files
add comments for ops LastLevelMaxPool to avoid potential confusion (#7593)
Co-authored-by: Nicolas Hug <[email protected]>
1 parent 19b2d3c commit abc40ef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

torchvision/ops/feature_pyramid_network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]:
206206

207207
class LastLevelMaxPool(ExtraFPNBlock):
208208
"""
209-
Applies a max_pool2d on top of the last feature map
209+
Applies a max_pool2d (not actual max_pool2d, we just subsample) on top of the last feature map
210210
"""
211211

212212
def forward(
@@ -216,7 +216,8 @@ def forward(
216216
names: List[str],
217217
) -> Tuple[List[Tensor], List[str]]:
218218
names.append("pool")
219-
x.append(F.max_pool2d(x[-1], 1, 2, 0))
219+
# Use max pooling to simulate stride 2 subsampling
220+
x.append(F.max_pool2d(x[-1], kernel_size=1, stride=2, padding=0))
220221
return x, names
221222

222223

0 commit comments

Comments
 (0)