From 73ebf8f7e244b6e50febeba8223292ca281a622c Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 28 Dec 2020 14:43:41 +0100 Subject: [PATCH 01/22] Update spec --- docs/ops/pooling/MaxPool_1.md | 68 ++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index d5c8701a033e64..a16b3c41ddbf57 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/pooling.html) -**Detailed description**: [Reference](http://cs231n.github.io/convolutional-networks/#pool) +**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. @@ -46,7 +46,7 @@ * *rounding_type* - * **Description**: *rounding_type* is a type of rounding to be applied. + * **Description**: *rounding_type* is a type of rounding to used to compute output shape. * **Range of values**: * *ceil* * *floor* @@ -69,6 +69,12 @@ * **1**: 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 corressponding output shape will be (N,C,H_out), (N,C,H_out,W_out) or (N,C,H_out,W_out,D_out) + 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 + **Mathematical Formulation** \f[ @@ -79,8 +85,60 @@ ```xml - - ... - ... + + + + 1 + 3 + 32 + + + + + 1 + 3 + 32 + + + + + + + + + 1 + 3 + 32 + 32 + + + + + 1 + 3 + 17 + 17 + + + + + + + + + 1 + 3 + 32 + 32 + + + + + 1 + 3 + 16 + 16 + + ``` \ No newline at end of file From 3cf4ac6ec13c72fe5a274dfd5d9d9e9fbc388009 Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 28 Dec 2020 14:56:16 +0100 Subject: [PATCH 02/22] Update outputs section --- docs/ops/pooling/MaxPool_1.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index a16b3c41ddbf57..a5b9b2e01e97e4 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -71,8 +71,11 @@ **Outputs**: * **1**: Input shape can be either (N,C,H), (N,C,H,W) or (N,C,H,W,D). Then the corressponding output shape will be (N,C,H_out), (N,C,H_out,W_out) or (N,C,H_out,W_out,D_out) + 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 **Mathematical Formulation** From b1ddfad632c4e7cb1de68ad9c1d88b6871e5bdd5 Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 28 Dec 2020 15:08:03 +0100 Subject: [PATCH 03/22] Update rounding_type section --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index a5b9b2e01e97e4..37a7c377737927 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -46,7 +46,7 @@ * *rounding_type* - * **Description**: *rounding_type* is a type of rounding to used to compute output shape. + * **Description**: *rounding_type* is a type of rounding to be used to compute output shape. * **Range of values**: * *ceil* * *floor* From 9d221e23c4a59784895d12478777bb2c2adfe9b9 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 29 Dec 2020 11:25:43 +0100 Subject: [PATCH 04/22] Update spec --- docs/ops/pooling/MaxPool_1.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 37a7c377737927..a54d66098780bb 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,10 @@ **Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/pooling.html) -**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. +**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is 0. + `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. @@ -70,13 +73,7 @@ * **1**: 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 corressponding output shape will be (N,C,H_out), (N,C,H_out,W_out) or (N,C,H_out,W_out,D_out) - - 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 + * **1**: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] **Mathematical Formulation** From bf1c7dc683319ef51288c433cbc1ecc11ff7a858 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 29 Dec 2020 11:26:47 +0100 Subject: [PATCH 05/22] Update input section --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index a54d66098780bb..561dcd75b00bde 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -70,7 +70,7 @@ **Inputs**: -* **1**: 4D or 5D input tensor. Required. +* **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 will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] From 86658008e2f3f32eda323652c10cfe2ea453b0a7 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 29 Dec 2020 11:33:33 +0100 Subject: [PATCH 06/22] add newline --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 561dcd75b00bde..cd39f50400ce11 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/pooling.html) -**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is 0. +**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is 0. `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` From 6af32dd53b2251a7c7d8828e879ebad4fc0db633 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 29 Dec 2020 11:34:35 +0100 Subject: [PATCH 07/22] fix one xml example --- docs/ops/pooling/MaxPool_1.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index cd39f50400ce11..5319385404625a 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -91,6 +91,7 @@ 1 3 32 + 32 @@ -98,6 +99,7 @@ 1 3 32 + 32 From 46584be66d9c37492a65980ef8b3609c5a724862 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 29 Dec 2020 11:35:25 +0100 Subject: [PATCH 08/22] fix indentation --- docs/ops/pooling/MaxPool_1.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 5319385404625a..027eafa3e5be42 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -95,12 +95,12 @@ - + 1 3 32 32 - + @@ -115,12 +115,12 @@ - + 1 3 17 17 - + @@ -135,12 +135,12 @@ - + 1 3 16 16 - + ``` \ No newline at end of file From d5e9a811776b0501770fe7d1c7f3189a3b7d5183 Mon Sep 17 00:00:00 2001 From: pszmel Date: Wed, 13 Jan 2021 15:38:07 +0100 Subject: [PATCH 09/22] Update detailed description --- docs/ops/pooling/MaxPool_1.md | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 027eafa3e5be42..c9666ac0e08c5b 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -11,6 +11,75 @@ `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` +Example 1 shows how *MaxPool* operates with `auto_pad = explicit` + +``` +input = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "explicit" +output = [[1, 2, 3, 3], + [4, 5, 6, 6], + [7, 8, 9, 9], + [7, 8, 9, 9]] +``` + +Example 2 shows how *MaxPool* operates with `auto_pad = valid` + +``` +input = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "valid" +output = [[5, 6], + [8, 9]] +``` + + +Example 3 shows how *MaxPool* operates with `auto_pad = same_upper` + +``` +input = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "same_upper" +output = [[1, 2, 3], + [4, 5, 6] + [7, 8, 9]] +``` + +Example 4 shows how *MaxPool* operates with `auto_pad = same_lower` + +``` +input = [[1, 2, 3], + [4, 5, 6], + [7, 8, 9]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "same_lower" +output = [[5, 6, 6], + [8, 9, 9] + [8, 9, 9]] +``` + **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. * *strides* From 1620158517819249097e4deb4341957017f78b33 Mon Sep 17 00:00:00 2001 From: pszmel Date: Wed, 13 Jan 2021 20:19:31 +0100 Subject: [PATCH 10/22] Update detailed description --- docs/ops/pooling/MaxPool_1.md | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index c9666ac0e08c5b..ec95469931c305 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/pooling.html) -**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is 0. +**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. `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` @@ -14,34 +14,34 @@ Example 1 shows how *MaxPool* operates with `auto_pad = explicit` ``` -input = [[1, 2, 3], - [4, 5, 6], - [7, 8, 9]] +input = [[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]] strides = [1, 1] pads_begin = [1, 1] pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "explicit" -output = [[1, 2, 3, 3], - [4, 5, 6, 6], - [7, 8, 9, 9], - [7, 8, 9, 9]] +output = [[-1, 2, 3, 3], + [4, 5, 5, -6], + [4, 8, 9, 9], + [-7, 8, 9, 9]] ``` Example 2 shows how *MaxPool* operates with `auto_pad = valid` ``` -input = [[1, 2, 3], - [4, 5, 6], - [7, 8, 9]] +input = [[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]] strides = [1, 1] pads_begin = [1, 1] pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "valid" -output = [[5, 6], +output = [[5, 5], [8, 9]] ``` @@ -49,33 +49,33 @@ output = [[5, 6], Example 3 shows how *MaxPool* operates with `auto_pad = same_upper` ``` -input = [[1, 2, 3], - [4, 5, 6], - [7, 8, 9]] +input = [[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]] strides = [1, 1] pads_begin = [1, 1] pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "same_upper" -output = [[1, 2, 3], - [4, 5, 6] - [7, 8, 9]] +output = [[-1, 2, 3], + [4, 5, 5] + [4, 8, 9]] ``` Example 4 shows how *MaxPool* operates with `auto_pad = same_lower` ``` -input = [[1, 2, 3], - [4, 5, 6], - [7, 8, 9]] +input = [[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]] strides = [1, 1] pads_begin = [1, 1] pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "same_lower" -output = [[5, 6, 6], +output = [[5, 5, -6], [8, 9, 9] [8, 9, 9]] ``` From 1a0fd0913ab8c3cdc57b9c607f8e5da14f25bb2a Mon Sep 17 00:00:00 2001 From: pszmel Date: Thu, 14 Jan 2021 13:55:45 +0100 Subject: [PATCH 11/22] Update spec --- docs/ops/pooling/MaxPool_1.md | 199 +++++++++++++++++++++------------- 1 file changed, 121 insertions(+), 78 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index ec95469931c305..1a13a9f4edf1c2 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -4,81 +4,9 @@ **Category**: *Pooling* -**Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/pooling.html) +**Short description**: Performs max pooling operation on input. -**Detailed description**: [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s). Input shape can be either 3D, 4D or 5D. Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. - `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` - -Example 1 shows how *MaxPool* operates with `auto_pad = explicit` - -``` -input = [[-1, 2, 3], - [4, 5, -6], - [-7, 8, 9]] -strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] -kernel = [2, 2] -rounding_type = "floor" -auto_pad = "explicit" -output = [[-1, 2, 3, 3], - [4, 5, 5, -6], - [4, 8, 9, 9], - [-7, 8, 9, 9]] -``` - -Example 2 shows how *MaxPool* operates with `auto_pad = valid` - -``` -input = [[-1, 2, 3], - [4, 5, -6], - [-7, 8, 9]] -strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] -kernel = [2, 2] -rounding_type = "floor" -auto_pad = "valid" -output = [[5, 5], - [8, 9]] -``` - - -Example 3 shows how *MaxPool* operates with `auto_pad = same_upper` - -``` -input = [[-1, 2, 3], - [4, 5, -6], - [-7, 8, 9]] -strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] -kernel = [2, 2] -rounding_type = "floor" -auto_pad = "same_upper" -output = [[-1, 2, 3], - [4, 5, 5] - [4, 8, 9]] -``` - -Example 4 shows how *MaxPool* operates with `auto_pad = same_lower` - -``` -input = [[-1, 2, 3], - [4, 5, -6], - [-7, 8, 9]] -strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] -kernel = [2, 2] -rounding_type = "floor" -auto_pad = "same_lower" -output = [[5, 5, -6], - [8, 9, 9] - [8, 9, 9]] -``` +**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s)(Article about max pooling in Convolutional Networks). **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. @@ -145,12 +73,127 @@ output = [[5, 5, -6], * **1**: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] **Mathematical Formulation** +Outputshape calculation based on `auto_pad` and `rounding_type`: + * `auto_pad = explicit` and `rounding_type = floor` + `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` + `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` + `D_out = floor(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` + + * `auto_pad = valid` and `rounding_type = floor` + `H_out = floor(H - kernel[0] / strides[0]) + 1` + `W_out = floor(W - kernel[1] / strides[1]) + 1` + `D_out = floor(D - kernel[2] / strides[2]) + 1` + + * `auto_pad = same_upper/same_lower` and `rounding_type = floor` + `H_out = H` + `W_out = W` + `D_out = D` + + * `auto_pad = explicit` and `rounding_type = ceil` + `H_out = ceil(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` + `W_out = ceil(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` + `D_out = ceil(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` + + * `auto_pad = valid` and `rounding_type = ceil` + `H_out = ceil(H - kernel[0] / strides[0]) + 1` + `W_out = ceil(W - kernel[1] / strides[1]) + 1` + `D_out = ceil(D - kernel[2] / strides[2]) + 1` + + * `auto_pad = same_upper/same_lower` and `rounding_type = ceil` + `H_out = H` + `W_out = W` + `D_out = D` + +If `(H + pads_begin[i] + pads_end[i] - kernel[i]` is not divided by `strides[i]` evenly then the result is rounded with the respect to `rounding_type` attribute. - \f[ - output_{j} = max(x_{0}, ..., x_{i}) - \f] +Example 1 shows how *MaxPool* operates with `auto_pad = explicit` + +``` +input = [[[[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]]]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "explicit" +output = [[[[-1, 2, 3, 3], + [4, 5, 5, -6], + [4, 8, 9, 9], + [-7, 8, 9, 9]]]] +``` + +Example 2 shows how *MaxPool* operates with `auto_pad = valid` + +``` +input = [[[-1, 2, 3, 5, -7, 9, 1]]] +strides = [1] +pads_begin = [1] +pads_end = [1] +kernel = [3] +rounding_type = "floor" +auto_pad = "valid" +output = [[[3, 5, 5, 9, 9]]] +``` + +Example 3 shows how *MaxPool* operates with `auto_pad = same_lower` + +``` +input = [[[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "same_lower" +output = [[[[-1, 2, 3], + [4, 5, 5] + [4, 8, 9]]]] +``` + +Example 4 shows how *MaxPool* operates with `auto_pad = same_upper` + +``` +input = [[[[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]], + [[2, -1, 5], + [6, -7, 1], + [8, 2, -3]]]] +strides = [1, 1] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "floor" +auto_pad = "same_upper" +output = [[[[5, 5, -6], + [8, 9, 9] + [8, 9, 9]], + [[6, 5, 5], + [8, 2, 1], + [8, 2, -3]]]] +``` + +Example 5 shows how *MaxPool* operates with `auto_pad = valid` and `rounding_type = ceil` + +``` +input = [[[[-1, 2, 3], + [4, 5, -6], + [-7, 8, 9]]]] +strides = [2, 2] +pads_begin = [1, 1] +pads_end = [1, 1] +kernel = [2, 2] +rounding_type = "ceil" +auto_pad = "valid" +output = [[[[5, 3], + [8, 9]]]] +``` -**Example** +**Examples** ```xml From 48f3cce5f4db0ae5d4feba0554e0f740c77f8763 Mon Sep 17 00:00:00 2001 From: pszmel Date: Thu, 14 Jan 2021 14:00:23 +0100 Subject: [PATCH 12/22] Change reference name --- docs/ops/pooling/MaxPool_1.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 1a13a9f4edf1c2..878006b683cb82 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: Performs max pooling operation on input. -**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. [Reference](https://deeplizard.com/learn/video/ZjM_XQa5s6s)(Article about max pooling in Convolutional Networks). +**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. [Article about max pooling in Convolutional Networks](https://deeplizard.com/learn/video/ZjM_XQa5s6s). **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. @@ -74,10 +74,10 @@ **Mathematical Formulation** Outputshape calculation based on `auto_pad` and `rounding_type`: - * `auto_pad = explicit` and `rounding_type = floor` - `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` - `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` - `D_out = floor(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` + * `auto_pad = explicit` and `rounding_type = floor`\ + `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1`\ + `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1`\ + `D_out = floor(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1`\ * `auto_pad = valid` and `rounding_type = floor` `H_out = floor(H - kernel[0] / strides[0]) + 1` From 27faead2d0c6984ce4b9b6ce5c5a832e4ff06aef Mon Sep 17 00:00:00 2001 From: pszmel Date: Thu, 14 Jan 2021 14:03:22 +0100 Subject: [PATCH 13/22] add new line --- docs/ops/pooling/MaxPool_1.md | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 878006b683cb82..3657798a787923 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -73,36 +73,36 @@ * **1**: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] **Mathematical Formulation** -Outputshape calculation based on `auto_pad` and `rounding_type`: - * `auto_pad = explicit` and `rounding_type = floor`\ - `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1`\ - `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1`\ - `D_out = floor(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1`\ +Outputshape calculation based on `auto_pad` and `rounding_type`: + * `auto_pad = explicit` and `rounding_type = floor` + `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` + `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` + `D_out = floor(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` - * `auto_pad = valid` and `rounding_type = floor` - `H_out = floor(H - kernel[0] / strides[0]) + 1` - `W_out = floor(W - kernel[1] / strides[1]) + 1` - `D_out = floor(D - kernel[2] / strides[2]) + 1` + * `auto_pad = valid` and `rounding_type = floor` + `H_out = floor(H - kernel[0] / strides[0]) + 1` + `W_out = floor(W - kernel[1] / strides[1]) + 1` + `D_out = floor(D - kernel[2] / strides[2]) + 1` - * `auto_pad = same_upper/same_lower` and `rounding_type = floor` - `H_out = H` - `W_out = W` - `D_out = D` + * `auto_pad = same_upper/same_lower` and `rounding_type = floor` + `H_out = H` + `W_out = W` + `D_out = D` - * `auto_pad = explicit` and `rounding_type = ceil` - `H_out = ceil(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` - `W_out = ceil(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` - `D_out = ceil(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` + * `auto_pad = explicit` and `rounding_type = ceil` + `H_out = ceil(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` + `W_out = ceil(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` + `D_out = ceil(D + pads_begin[2] + pads_end[2] - kernel[2] / strides[2]) + 1` - * `auto_pad = valid` and `rounding_type = ceil` - `H_out = ceil(H - kernel[0] / strides[0]) + 1` - `W_out = ceil(W - kernel[1] / strides[1]) + 1` - `D_out = ceil(D - kernel[2] / strides[2]) + 1` + * `auto_pad = valid` and `rounding_type = ceil` + `H_out = ceil(H - kernel[0] / strides[0]) + 1` + `W_out = ceil(W - kernel[1] / strides[1]) + 1` + `D_out = ceil(D - kernel[2] / strides[2]) + 1` - * `auto_pad = same_upper/same_lower` and `rounding_type = ceil` - `H_out = H` - `W_out = W` - `D_out = D` + * `auto_pad = same_upper/same_lower` and `rounding_type = ceil` + `H_out = H` + `W_out = W` + `D_out = D` If `(H + pads_begin[i] + pads_end[i] - kernel[i]` is not divided by `strides[i]` evenly then the result is rounded with the respect to `rounding_type` attribute. From 82989f109538716552c192d10b224af8b2f64cac Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 18 Jan 2021 12:52:46 +0100 Subject: [PATCH 14/22] Update spec --- docs/ops/pooling/MaxPool_1.md | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 3657798a787923..c5cd830f87ec65 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -63,7 +63,7 @@ * **Type**: string * **Default value**: *explicit* * **Required**: *no* - * **Note**: *pads_begin* and *pads_end* attributes are ignored when *auto_pad* is specified. + * **Note**: *pads_begin* and *pads_end* attributes are ignored when *auto_pad* is not equal to explicit. **Inputs**: @@ -104,9 +104,9 @@ Outputshape calculation based on `auto_pad` and `rounding_type`: `W_out = W` `D_out = D` -If `(H + pads_begin[i] + pads_end[i] - kernel[i]` is not divided by `strides[i]` evenly then the result is rounded with the respect to `rounding_type` attribute. +If `H + pads_begin[i] + pads_end[i] - kernel[i]` is not divided by `strides[i]` evenly then the result is rounded with the respect to `rounding_type` attribute. -Example 1 shows how *MaxPool* operates with `auto_pad = explicit` +Example 1 shows how *MaxPool* operates with 4D input using 2D kernel and `auto_pad = explicit` ``` input = [[[[-1, 2, 3], @@ -124,28 +124,24 @@ output = [[[[-1, 2, 3, 3], [-7, 8, 9, 9]]]] ``` -Example 2 shows how *MaxPool* operates with `auto_pad = valid` +Example 2 shows how *MaxPool* operates with 3D input using 1D kernel and `auto_pad = valid` ``` input = [[[-1, 2, 3, 5, -7, 9, 1]]] strides = [1] -pads_begin = [1] -pads_end = [1] kernel = [3] rounding_type = "floor" auto_pad = "valid" output = [[[3, 5, 5, 9, 9]]] ``` -Example 3 shows how *MaxPool* operates with `auto_pad = same_lower` +Example 3 shows how *MaxPool* operates with 4D input using 2D kernel `auto_pad = same_lower` ``` -input = [[[-1, 2, 3], +input = [[[[-1, 2, 3], [4, 5, -6], - [-7, 8, 9]]] + [-7, 8, 9]]]] strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "same_lower" @@ -154,7 +150,7 @@ output = [[[[-1, 2, 3], [4, 8, 9]]]] ``` -Example 4 shows how *MaxPool* operates with `auto_pad = same_upper` +Example 4 shows how *MaxPool* operates with 4D input using 2D kernel and `auto_pad = same_upper` ``` input = [[[[-1, 2, 3], @@ -164,8 +160,6 @@ input = [[[[-1, 2, 3], [6, -7, 1], [8, 2, -3]]]] strides = [1, 1] -pads_begin = [1, 1] -pads_end = [1, 1] kernel = [2, 2] rounding_type = "floor" auto_pad = "same_upper" @@ -184,8 +178,6 @@ input = [[[[-1, 2, 3], [4, 5, -6], [-7, 8, 9]]]] strides = [2, 2] -pads_begin = [1, 1] -pads_end = [1, 1] kernel = [2, 2] rounding_type = "ceil" auto_pad = "valid" @@ -197,7 +189,7 @@ output = [[[[5, 3], ```xml - + 1 @@ -237,7 +229,7 @@ output = [[[[5, 3], - + 1 From ed37055eb7aa4f8c798493e79b3b7723882328ea Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 18 Jan 2021 12:55:30 +0100 Subject: [PATCH 15/22] fix typo --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index c5cd830f87ec65..b86e2508b4b5b1 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -73,7 +73,7 @@ * **1**: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] **Mathematical Formulation** -Outputshape calculation based on `auto_pad` and `rounding_type`: +Outputs hape calculation based on `auto_pad` and `rounding_type`: * `auto_pad = explicit` and `rounding_type = floor` `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` From fa3e0ca5a02524e8c0874fd83963f57839ceb416 Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 18 Jan 2021 12:58:14 +0100 Subject: [PATCH 16/22] fix style --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index b86e2508b4b5b1..12fa2ac33f0f2b 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -73,7 +73,7 @@ * **1**: Input shape can be either [N,C,H], [N,C,H,W] or [N,C,H,W,D]. Then the corresponding output shape will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] **Mathematical Formulation** -Outputs hape calculation based on `auto_pad` and `rounding_type`: +Output shape calculation based on `auto_pad` and `rounding_type`: * `auto_pad = explicit` and `rounding_type = floor` `H_out = floor(H + pads_begin[0] + pads_end[0] - kernel[0] / strides[0]) + 1` `W_out = floor(W + pads_begin[1] + pads_end[1] - kernel[1] / strides[1]) + 1` From 46142ddf0d5c1df45cef1a7101bb7ee28df25e2e Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 18 Jan 2021 13:01:36 +0100 Subject: [PATCH 17/22] fix example 5 description --- docs/ops/pooling/MaxPool_1.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 12fa2ac33f0f2b..d841eaf355b56c 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -135,7 +135,7 @@ auto_pad = "valid" output = [[[3, 5, 5, 9, 9]]] ``` -Example 3 shows how *MaxPool* operates with 4D input using 2D kernel `auto_pad = same_lower` +Example 3 shows how *MaxPool* operates with 4D input using 2D kernel and `auto_pad = same_lower` ``` input = [[[[-1, 2, 3], @@ -171,7 +171,7 @@ output = [[[[5, 5, -6], [8, 2, -3]]]] ``` -Example 5 shows how *MaxPool* operates with `auto_pad = valid` and `rounding_type = ceil` +Example 5 shows how *MaxPool* operates with 4D input using 2D kernel, `auto_pad = valid` and `rounding_type = ceil` ``` input = [[[[-1, 2, 3], From 22bffc94dff4292790b92f230f7025c9de457910 Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 1 Feb 2021 13:49:44 +0100 Subject: [PATCH 18/22] Update spec --- docs/ops/pooling/MaxPool_1.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index de844b61a975fe..65f2a29755b21c 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: Performs max pooling operation on input. -**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value is `-inf`. [Article about max pooling in Convolutional Networks](https://deeplizard.com/learn/video/ZjM_XQa5s6s). +**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value are `-inf`. The max pooling operation involves sliding a filter over each channel of feature map and down sampling by choosing the biggest value within the region covered by the filter. [Article about max pooling in Convolutional Networks](https://deeplizard.com/learn/video/ZjM_XQa5s6s). **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. @@ -68,12 +68,9 @@ **Inputs**: * **1**: 3D, 4D or 5D input tensor. Required. -<<<<<<< HEAD **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 will be [N,C,H_out], [N,C,H_out,W_out] or [N,C,H_out,W_out,D_out] -======= ->>>>>>> upstream/master + * **1**: Input shape can be either `[N, C, H]`, `[N, C, H, W]` or `[N, C, H, W, D]`. Then the corresponding output shape will be `[N, C, H_out]`, `[N, C, H_out, W_out]` or `[N, C, H_out, W_out, D_out]` **Mathematical Formulation** Output shape calculation based on `auto_pad` and `rounding_type`: From e7ac30d8b64b8fb9e5b96546b56c27eba9cbfb8c Mon Sep 17 00:00:00 2001 From: pszmel Date: Mon, 1 Feb 2021 14:57:03 +0100 Subject: [PATCH 19/22] Add Types section --- docs/ops/pooling/MaxPool_1.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 65f2a29755b21c..f4c4001a9c8b1c 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -6,7 +6,7 @@ **Short description**: Performs max pooling operation on input. -**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value are `-inf`. The max pooling operation involves sliding a filter over each channel of feature map and down sampling by choosing the biggest value within the region covered by the filter. [Article about max pooling in Convolutional Networks](https://deeplizard.com/learn/video/ZjM_XQa5s6s). +**Detailed description**: Input shape can be either 3D, 4D or 5D. Max Pooling operation is performed with the respect to input shape from the third dimension to the last dimension. If paddings are used then during the pooling calculation their value are `-inf`. The Max Pooling operation involves sliding a filter over each channel of feature map and downsampling by choosing the biggest value within the region covered by the filter. [Article about max pooling in Convolutional Networks](https://deeplizard.com/learn/video/ZjM_XQa5s6s). **Attributes**: *Pooling* attributes are specified in the `data` node, which is a child of the layer node. @@ -67,10 +67,14 @@ **Inputs**: -* **1**: 3D, 4D or 5D input tensor. Required. +* **1**: 3D, 4D or 5D input tensor of type T. 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 will be `[N, C, H_out]`, `[N, C, H_out, W_out]` or `[N, C, H_out, W_out, D_out]` + * **1**: Input shape can be either `[N, C, H]`, `[N, C, H, W]` or `[N, C, H, W, D]`. Then the corresponding output shape will be `[N, C, H_out]`, `[N, C, H_out, W_out]` or `[N, C, H_out, W_out, D_out]`. Output tensor has the same data type as input tensor. + +**Types** + +* *T*: `uint64`, `int32`, `int64`, `float16`, `float32`. **Mathematical Formulation** Output shape calculation based on `auto_pad` and `rounding_type`: From e7b64d96affbac0a6a74b2f48b25b3898b86e879 Mon Sep 17 00:00:00 2001 From: pszmel Date: Tue, 2 Feb 2021 22:45:10 +0100 Subject: [PATCH 20/22] Refactor xml examples --- docs/ops/pooling/MaxPool_1.md | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index f4c4001a9c8b1c..4edef54a239d78 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -193,62 +193,62 @@ output = [[[[5, 3], ```xml - - - + + + 1 3 32 32 - - - - + + + + 1 3 32 32 - + - - - + + + 1 3 32 32 - - - - + + + + 1 3 17 17 - + - - - + + + 1 3 32 32 - - - - + + + + 1 3 16 16 - + ``` \ No newline at end of file From 055a28dae5c9a24e1f1bfbe59cc0805d526a41b7 Mon Sep 17 00:00:00 2001 From: pszmel Date: Thu, 4 Feb 2021 11:04:39 +0100 Subject: [PATCH 21/22] Update xml examples and add bfloat16 to supported types --- docs/ops/pooling/MaxPool_1.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 4edef54a239d78..4662bc0f26070c 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -74,7 +74,7 @@ **Types** -* *T*: `uint64`, `int32`, `int64`, `float16`, `float32`. +* *T*: `uint64`, `int32`, `int64`, `float16`, `float32`, `bfloat16`. **Mathematical Formulation** Output shape calculation based on `auto_pad` and `rounding_type`: @@ -193,7 +193,7 @@ output = [[[[5, 3], ```xml - + 1 @@ -233,7 +233,7 @@ output = [[[[5, 3], - + 1 From f8a0810e7ea13bba7d29e98e89427f4943f47bb5 Mon Sep 17 00:00:00 2001 From: pszmel Date: Thu, 4 Feb 2021 12:47:00 +0100 Subject: [PATCH 22/22] Update supported types --- docs/ops/pooling/MaxPool_1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ops/pooling/MaxPool_1.md b/docs/ops/pooling/MaxPool_1.md index 4662bc0f26070c..5b73c9b21c59ec 100644 --- a/docs/ops/pooling/MaxPool_1.md +++ b/docs/ops/pooling/MaxPool_1.md @@ -74,7 +74,7 @@ **Types** -* *T*: `uint64`, `int32`, `int64`, `float16`, `float32`, `bfloat16`. +* *T*: floating point or integer type. **Mathematical Formulation** Output shape calculation based on `auto_pad` and `rounding_type`: