提交 ada54ba5 编写于 作者: M Megvii Engine Team

docs(mge): update AvgPool2d & functional.nn.avg_pool2d example

GitOrigin-RevId: e2859c7f99a52002a483815fc4993712216c0abd
上级 d8ea0168
......@@ -709,8 +709,9 @@ def avg_pool2d(
output tensor of shape :math:`(N, C, H_{\text{out}}, W_{\text{out}})`.
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]
[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
to "average" will do counting.
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__(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册