FractionalMaxPool3d#
- class torch.nn.FractionalMaxPool3d(kernel_size, output_size=None, output_ratio=None, return_indices=False, _random_samples=None)[source]#
对由多个输入平面组成的输入信号应用 3D 分数最大池化。
Fractional MaxPooling 的详细描述请参见论文 Fractional MaxPooling (作者: Ben Graham)。
最大池化操作是在 区域中执行的,步长由目标输出大小随机确定。输出特征的数量等于输入平面的数量。
注意
必须定义
output_size
或output_ratio
中的一个且仅一个。- 参数
kernel_size (Union[int, tuple[int, int, int]]) – 取最大值的窗口大小。可以是单个数字 k(表示 k x k x k 的方形核)或一个元组 (kt x kh x kw),k 必须大于 0。
output_size (Union[int, tuple[int, int, int]]) – 图像的目标输出大小,形式为 oT x oH x oW。可以是一个元组 (oT, oH, oW) 或一个表示方形图像 oH x oH x oH 的单个数字 oH。
output_ratio (Union[float, tuple[float, float, float]]) – 如果希望输出大小是输入大小的比例,可以使用此选项。这必须是一个在 (0, 1) 范围内的数字或元组。
return_indices (bool) – 如果为
True
,则会返回索引以及输出。这对于传递给nn.MaxUnpool3d()
非常有用。默认为False
。
- 形状
输入: 或 。
输出: 或 ,其中 或
示例
>>> # pool of cubic window of size=3, and target output size 13x12x11 >>> m = nn.FractionalMaxPool3d(3, output_size=(13, 12, 11)) >>> # pool of cubic window and target output size being half of input size >>> m = nn.FractionalMaxPool3d(3, output_ratio=(0.5, 0.5, 0.5)) >>> input = torch.randn(20, 16, 50, 32, 16) >>> output = m(input)