maxpool

Creates a max pool operation that performs the computation required to implement a max pooling layer.

maxpool
(
,
size_t[] dims
,
string mod = __MODULE__
,
size_t line = __LINE__
)

Parameters

features
Type: Operation

A tensor containing a batch of input feature maps.

dims
Type: size_t[]

An array of pool dims.

Return Value

Type: Operation

An operation representing a max pool computation.

Examples

1 import dopt.core : evaluate;
2 
3 auto features = float32([1, 1, 4, 4], [
4     1.0f, 2.0f, 4.0f, 3.0f,
5     5.0f, 3.0f, 2.0f, 2.0f,
6     0.1f, -4.0f, 3.0f, 2.0f,
7     0.0f, 0.0f, 2.0f, 2.0f
8 ]);
9 
10 auto result = features.maxpool([2,2]);
11 
12 auto pooledFeatures = result.evaluate().as!float;
13 
14 assert(pooledFeatures == [
15     5.0f, 4.0f,
16     0.1f, 3.0f
17 ]);

Meta