nn.max_pool
MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized.
Args
X
(@Tensor<T>
) - Input data tensor from the previous operator; dimensions for image case are (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data. For non image case, the dimensions are in the form of (N x C x D1 x D2 ... Dn), where N is the batch size.auto_pad
(Option<AUTO_PAD>
) - Default is NOTSET, auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. NOTSET means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so thatoutput_shape[i] = ceil(input_shape[i] / strides[i])
for each axisi
.ceil_mode
(Option<usize>
) - Default is 1, Whether to use ceil or floor (default) to compute the output shape.dilations
(Option<Span<usize>>
) - Dilation value along each spatial axis of the filter. If not present, the dilation defaults to 1 along each spatial axis.kernel_shape
(Span<usize>
) - The size of the kernel along each axis.pads
(Option<Span<usize>>
) - Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis.pads
format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axisi
and xi_end, the number of pixels added at the end of axisi
. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.storage_order
(Option<usize>
) - Default is 0, The storage order of the tensor. 0 is row major, and 1 is column major.strides
(Option<Span<usize>>
) - Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.output_len
(Option<usize>
) - Default is 1, If set to 2, return the indices tensor.
Returns
A Tensor<T>
that contains the result of the max pool. A Option<Tensor<usize>>
with the indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor.
Examples
Last updated