Args: spatial_dims: number of spatial dimensions of the input image. kernel_size: the kernel size of both pooling operations. stride: the stride of the window. Default value is `kernel_size`. padding: implicit zero padding to be added to both
(
self,
spatial_dims: int,
kernel_size: Sequence[int] | int,
stride: Sequence[int] | int | None = None,
padding: Sequence[int] | int = 0,
ceil_mode: bool = False,
)
| 30 | """ |
| 31 | |
| 32 | def __init__( |
| 33 | self, |
| 34 | spatial_dims: int, |
| 35 | kernel_size: Sequence[int] | int, |
| 36 | stride: Sequence[int] | int | None = None, |
| 37 | padding: Sequence[int] | int = 0, |
| 38 | ceil_mode: bool = False, |
| 39 | ) -> None: |
| 40 | """ |
| 41 | Args: |
| 42 | spatial_dims: number of spatial dimensions of the input image. |
| 43 | kernel_size: the kernel size of both pooling operations. |
| 44 | stride: the stride of the window. Default value is `kernel_size`. |
| 45 | padding: implicit zero padding to be added to both pooling operations. |
| 46 | ceil_mode: when True, will use ceil instead of floor to compute the output shape. |
| 47 | """ |
| 48 | super().__init__() |
| 49 | _params = { |
| 50 | "kernel_size": ensure_tuple_rep(kernel_size, spatial_dims), |
| 51 | "stride": None if stride is None else ensure_tuple_rep(stride, spatial_dims), |
| 52 | "padding": ensure_tuple_rep(padding, spatial_dims), |
| 53 | "ceil_mode": ceil_mode, |
| 54 | } |
| 55 | self.max_pool = Pool[Pool.MAX, spatial_dims](**_params) |
| 56 | self.avg_pool = Pool[Pool.AVG, spatial_dims](**_params) |
| 57 | |
| 58 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 59 | """ |
no test coverage detected