Skip to content

Commit ee24a05

Browse files
xuy111soumith
authored andcommitted
change doc for Adaptive Pooling
1 parent f3519fd commit ee24a05

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

torch/nn/modules/pooling.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,9 @@ class AdaptiveMaxPool2d(Module):
871871
872872
Args:
873873
output_size: the target output size of the image of the form H x W.
874-
Can be a tuple (H, W) or a single number H for a square image H x H
874+
Can be a tuple (H, W) or a single H for a square image H x H.
875+
H and W can be either a ``int``, or ``None`` which means the size will
876+
be the same as that of the input.
875877
return_indices: if ``True``, will return the indices along with the outputs.
876878
Useful to pass to nn.MaxUnpool2d. Default: ``False``
877879
@@ -884,6 +886,10 @@ class AdaptiveMaxPool2d(Module):
884886
>>> m = nn.AdaptiveMaxPool2d(7)
885887
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9))
886888
>>> output = m(input)
889+
>>> # target output size of 10x7
890+
>>> m = nn.AdaptiveMaxPool2d((None, 7))
891+
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9))
892+
>>> output = m(input)
887893
888894
"""
889895

@@ -908,7 +914,10 @@ class AdaptiveMaxPool3d(Module):
908914
909915
Args:
910916
output_size: the target output size of the image of the form D x H x W.
911-
Can be a tuple (D, H, W) or a single number D for a cube D x D x D
917+
Can be a tuple (D, H, W) or a single D for a cube D x D x D.
918+
D, H and W can be either a ``int``, or ``None`` which means the size will
919+
be the same as that of the input.
920+
912921
return_indices: if ``True``, will return the indices along with the outputs.
913922
Useful to pass to nn.MaxUnpool3d. Default: ``False``
914923
@@ -921,6 +930,10 @@ class AdaptiveMaxPool3d(Module):
921930
>>> m = nn.AdaptiveMaxPool3d(7)
922931
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9, 8))
923932
>>> output = m(input)
933+
>>> # target output size of 7x9x8
934+
>>> m = nn.AdaptiveMaxPool3d((7, None, None))
935+
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9, 8))
936+
>>> output = m(input)
924937
925938
"""
926939

@@ -974,7 +987,9 @@ class AdaptiveAvgPool2d(Module):
974987
975988
Args:
976989
output_size: the target output size of the image of the form H x W.
977-
Can be a tuple (H, W) or a single number H for a square image H x H
990+
Can be a tuple (H, W) or a single H for a square image H x H
991+
H and W can be either a ``int``, or ``None`` which means the size will
992+
be the same as that of the input.
978993
979994
Examples:
980995
>>> # target output size of 5x7
@@ -985,6 +1000,10 @@ class AdaptiveAvgPool2d(Module):
9851000
>>> m = nn.AdaptiveAvgPool2d(7)
9861001
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9))
9871002
>>> output = m(input)
1003+
>>> # target output size of 10x7
1004+
>>> m = nn.AdaptiveMaxPool2d((None, 7))
1005+
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9))
1006+
>>> output = m(input)
9881007
9891008
"""
9901009

@@ -1009,6 +1028,8 @@ class AdaptiveAvgPool3d(Module):
10091028
Args:
10101029
output_size: the target output size of the form D x H x W.
10111030
Can be a tuple (D, H, W) or a single number D for a cube D x D x D
1031+
D, H and W can be either a ``int``, or ``None`` which means the size will
1032+
be the same as that of the input.
10121033
10131034
Examples:
10141035
>>> # target output size of 5x7x9
@@ -1019,6 +1040,10 @@ class AdaptiveAvgPool3d(Module):
10191040
>>> m = nn.AdaptiveAvgPool3d(7)
10201041
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9, 8))
10211042
>>> output = m(input)
1043+
>>> # target output size of 7x9x8
1044+
>>> m = nn.AdaptiveMaxPool3d((7, None, None))
1045+
>>> input = autograd.Variable(torch.randn(1, 64, 10, 9, 8))
1046+
>>> output = m(input)
10221047
10231048
"""
10241049

0 commit comments

Comments
 (0)