AdaptiveMaxPool2d ¬
- class torch.nn.AdaptiveMaxPool2d(output_size, return_indices=False)[source][source] ¬
在由多个输入平面组成的输入信号上应用 2D 自适应最大池化。
输出大小为 ,适用于任何输入大小。输出特征的数量等于输入平面的数量。
- 参数:
output_size(Union[int, None, tuple[Optional[int], Optional[int]]])- 目标输出图像的大小为 。可以是元组 或单个 用于正方形图像 。 和 可以是
int
,或None
,表示大小将与输入相同。return_indices(bool)- 如果
True
,将返回索引和输出。对 nn.MaxUnpool2d 很有用。默认值:False
- 形状:
输入: 或 。
输出: 或 ,其中 。
示例
>>> # target output size of 5x7 >>> m = nn.AdaptiveMaxPool2d((5, 7)) >>> input = torch.randn(1, 64, 8, 9) >>> output = m(input) >>> # target output size of 7x7 (square) >>> m = nn.AdaptiveMaxPool2d(7) >>> input = torch.randn(1, 64, 10, 9) >>> output = m(input) >>> # target output size of 10x7 >>> m = nn.AdaptiveMaxPool2d((None, 7)) >>> input = torch.randn(1, 64, 10, 9) >>> output = m(input)