Files
openvino/docs/ops/pooling/AvgPool_1.md
Anton Chetverikov 6b54e738d7 Update operation attributes (#3814)
* Allign attribute values in spec

* Fix wrong attribute name in spec

* Add `get_boolean_attr` function

* Add get_type function

* Update conv attrs

* Update copyright year

* Add missed attrs, update copyright year

* Fix year in copyright

* Update ir parser for RegionYolo layer

* Remove wrong changes for BinaryConvolution

* Remove get_type function as it no more needed

* Update check for reduce ops

* Fix error in reduce attrs

* Update ir_engine to work with bool attrs

* Update DetectionOutput operation

* Update PSROIPooling

* remove redundant attrs from spec

* Update get_boolean_attr function

* Update Reduce operations

* Update DetectionOutput specification

* Update specification for missed attrs

* Apply comments

* Fixconst renumbering logic

* Fix typo

* Change default value to fix broken shape inference

* Add additional asserts

* Add comment

* model-optimizer/mo/utils/ir_reader/layer_to_class.py

* Sort imports

* Sort imports

* Update year in copyright

* Update const

* Remove changes from const restoring

* Rename function

* remove unnecessary changes

* model-optimizer/mo/front/extractor_test.py

* Fix year in copyright

* Add soft_get

* Fix exclude-pad attribute name for AvgPool operation

* Update exclude_pad attribute values

* Remove useless comment

* Update examples in specification

* Remove file added by mistake

* Resolve comments

* Resolve comments

* Add return value

* Allign global_pool attribute
2021-01-29 10:08:06 +03:00

6.3 KiB

AvgPool

Versioned name: AvgPool-1

Category: Pooling

Short description: Reference

Detailed description: Reference. Average Pool is a pooling operation that performs down-sampling by dividing the input into pooling regions of size specified by kernel attribute and computing the average values of each region. Output shape is calculated as follows: H_out = (H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1
W_out = (H + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1
D_out = (H + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1

Attributes: Pooling attributes are specified in the data node, which is a child of the layer node.

  • strides

    • Description: strides is a distance (in pixels) to slide the window on the feature map over the (z, y, x) axes for 3D poolings and (y, x) axes for 2D poolings. For example, strides equal "4,2,1" means sliding the window 4 pixel at a time over depth dimension, 2 over height dimension and 1 over width dimension.
    • Range of values: integer values starting from 0
    • Type: int[]
    • Default value: None
    • Required: yes
  • pads_begin

    • Description: pads_begin is a number of pixels to add to the beginning along each axis. For example, pads_begin equal "1,2" means adding 1 pixel to the top of the input and 2 to the left of the input.
    • Range of values: integer values starting from 0
    • Type: int[]
    • Default value: None
    • Required: yes
    • Note: the attribute is ignored when auto_pad attribute is specified.
  • pads_end

    • Description: pads_end is a number of pixels to add to the ending along each axis. For example, pads_end equal "1,2" means adding 1 pixel to the bottom of the input and 2 to the right of the input.
    • Range of values: integer values starting from 0
    • Type: int[]
    • Default value: None
    • Required: yes
    • Note: the attribute is ignored when auto_pad attribute is specified.
  • kernel

    • Description: kernel is a size of each filter. For example, kernel equal (2, 3) means that each filter has height equal to 2 and width equal to 3.
    • Range of values: integer values starting from 1
    • Type: int[]
    • Default value: None
    • Required: yes
  • exclude-pad

    • Description: exclude-pad is a type of pooling strategy for values in the padding area. For example, if exclude-pad is "true", then zero-values that came from padding are not included in averaging calculation.
    • Range of values: true or false
    • Type: boolean
    • Default value: None
    • Required: yes
  • rounding_type

    • Description: rounding_type is a type of rounding to be applied.
    • Range of values:
      • ceil
      • floor
    • Type: string
    • Default value: floor
    • Required: no
  • auto_pad

    • Description: auto_pad how the padding is calculated. Possible values:
      • explicit: use explicit padding values from pads_begin and pads_end.
      • same_upper (same_lower) the input is padded to match the output size. In case of odd padding value an extra padding is added at the end (at the beginning).
      • valid - do not use padding.
    • Type: string
    • Default value: explicit
    • Required: no
    • Note: pads_begin and pads_end attributes are ignored when auto_pad is specified.

Inputs:

  • 1: 3D, 4D or 5D input tensor. Required.

Outputs:

  • 1: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape is [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out].

Mathematical Formulation

\f[ output_{j} = \frac{\sum_{i = 0}^{n}x_{i}}{n} \f]

Examples

<layer ... type="AvgPool" ... >
    <data auto_pad="same_upper" exclude-pad="true" kernel="2,2" pads_begin="0,0" pads_end="1,1" strides="2,2"/>
    <input> 
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </input>
    <output>
        <port id="1">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </output>
</layer>

<layer ... type="AvgPool" ... >
    <data auto_pad="same_upper" exclude-pad="false" kernel="5,5" pads_begin="0,0" pads_end="1,1" strides="2,2"/>
    <input> 
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </input>
    <output>
        <port id="1">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </output>
</layer>

<layer ... type="AvgPool" ... >
    <data auto_pad="explicit" exclude-pad="true" kernel="5,5" pads_begin="1,1" pads_end="1,1" strides="3,3"/>
    <input> 
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </input>
    <output>
        <port id="1">
            <dim>1</dim>
            <dim>3</dim>
            <dim>10</dim>
            <dim>10</dim>
        </port>
    </output>
</layer>

<layer ... type="AvgPool" ... >
    <data auto_pad="explicit" exclude-pad="false" kernel="5,5" pads_begin="1,1" pads_end="1,1" strides="2,2"/>
    <input> 
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </input>
    <output>
        <port id="1">
            <dim>1</dim>
            <dim>3</dim>
            <dim>15</dim>
            <dim>15</dim>
        </port>
    </output>
</layer>

<layer ... type="AvgPool" ... >
    <data auto_pad="valid" exclude-pad="true" kernel="5,5" pads_begin="1,1" pads_end="1,1" strides="2,2"/>
    <input> 
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>32</dim>
            <dim>32</dim>
        </port>
    </input>
    <output>
        <port id="1">
            <dim>1</dim>
            <dim>3</dim>
            <dim>14</dim>
            <dim>14</dim>
        </port>
    </output>
</layer>