torch.nn.MaxPool2d
时间: 2023-10-26 13:37:04 浏览: 106
torch.nn.MaxPool2d is a module in PyTorch that performs 2D max pooling operation. It is used to downsample the input tensor along the spatial dimensions, i.e., width and height. The operation replaces each spatial area of the input tensor with the maximum value of that area.
The module takes the following inputs:
- kernel_size: The size of the window used for pooling.
- stride: The stride of the window used for pooling.
- padding: The amount of padding applied to the input tensor before the pooling operation.
- dilation: The spacing between the values within the kernel.
- ceil_mode: When set to True, the output size is rounded up instead of rounded down.
- return_indices: When set to True, the indices of the maximum values are returned along with the output tensor.
The output of the module is a tensor with dimensions (batch_size, channels, output_height, output_width), where output_height and output_width are calculated based on the input tensor dimensions, kernel_size, stride, padding, and dilation.
阅读全文