Browse Source

!561 add example for MaxPool and MaxPoolWithArgmax

Merge pull request !561 from jiangjinsheng/maxpool_example
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
f32e17308f
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      mindspore/ops/operations/nn_ops.py

+ 10
- 0
mindspore/ops/operations/nn_ops.py View File

@@ -859,6 +859,11 @@ class MaxPool(_Pool):

Outputs:
Tensor, with shape :math:`(N, C_{out}, H_{out}, W_{out})`.

Examples:
>>> input_tensor = Tensor(np.arange(1 * 3 * 3 * 4).reshape((1, 3, 3, 4)), mindspore.float32)
>>> maxpool_op = P.MaxPool(padding="VALID", ksize=2, strides=1)
>>> output_tensor = maxpool_op(input_tensor)
"""

@prim_attr_register
@@ -905,6 +910,11 @@ class MaxPoolWithArgmax(_Pool):

- **output** (Tensor) - Maxpooling result, with shape :math:`(N, C_{out}, H_{out}, W_{out})`.
- **mask** (Tensor) - Max values' index represented by the mask.

Examples:
>>> input_tensor = Tensor(np.arange(1 * 3 * 3 * 4).reshape((1, 3, 3, 4)), mindspore.float32)
>>> maxpool_arg_op = P.MaxPoolWithArgmax(padding="VALID", ksize=2, strides=1)
>>> output_tensor, argmax = maxpool_arg_op(input_tensor)
"""
def __init__(self, ksize=1, strides=1, padding="valid"):
super(MaxPoolWithArgmax, self).__init__(ksize, strides, padding)


Loading…
Cancel
Save