GitOrigin-RevId: e2859c7f99
release-1.11.1
@@ -709,8 +709,9 @@ def avg_pool2d( | |||||
output tensor of shape :math:`(N, C, H_{\text{out}}, W_{\text{out}})`. | output tensor of shape :math:`(N, C, H_{\text{out}}, W_{\text{out}})`. | ||||
Examples: | Examples: | ||||
>>> input = Tensor(np.arange(1 * 1 * 3 * 4).astype(np.float32).reshape(1, 1, 3, 4)) | |||||
>>> F.avg_pool2d(input, kernel_size=2, stride=2, padding=[1,0], mode="average") | |||||
>>> import numpy as np | |||||
>>> inp = Tensor(np.arange(1 * 1 * 3 * 4).astype(np.float32).reshape(1, 1, 3, 4)) | |||||
>>> F.avg_pool2d(inp, kernel_size=2, stride=2, padding=[1,0], mode="average") | |||||
Tensor([[[[0.25 1.25] | Tensor([[[[0.25 1.25] | ||||
[6.5 8.5 ]]]], device=xpux:0) | [6.5 8.5 ]]]], device=xpux:0) | ||||
""" | """ | ||||
@@ -88,6 +88,15 @@ class AvgPool2d(_PoolNd): | |||||
mode: whether to include the padding values while calculating the average, set | mode: whether to include the padding values while calculating the average, set | ||||
to "average" will do counting. | to "average" will do counting. | ||||
Default: "average_count_exclude_padding" | Default: "average_count_exclude_padding" | ||||
Examples: | |||||
>>> import numpy as np | |||||
>>> m = M.AvgPool2d(kernel_size=2, stride=2, padding=[1,0], mode="average") | |||||
>>> inp = mge.tensor(np.arange(1 * 1 * 3 * 4).astype(np.float32).reshape(1, 1, 3, 4)) | |||||
>>> output = m(inp) | |||||
Tensor([[[[0.25 1.25] | |||||
[6.5 8.5 ]]]], device=xpux:0) | |||||
""" | """ | ||||
def __init__( | def __init__( | ||||