我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用torch.nn.FractionalMaxPool2d()。
def pool(kernel_size, power=2, output_size=None, out_ratio=None, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False, mode='max', count_include_pad=True, _random_samples=None, dim=2): in_dim = dim if mode == 'max': if in_dim == 1: return nn.MaxPool1d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode) elif in_dim == 2: return nn.MaxPool2d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode) elif in_dim == 3: return nn.MaxPool3d(kernel_size=kernel_size, stride=stride, padding=padding, dilation=dilation, return_indices=return_indices, ceil_mode=ceil_mode) elif mode=='ave': if in_dim == 1: return nn.AvgPool1d(kernel_size=kernel_size, stride=stride, padding=padding, ceil_mode=ceil_mode, count_include_pad=count_include_pad) elif in_dim == 2: return nn.AvgPool2d(kernel_size=kernel_size, stride=stride, padding=padding, ceil_mode=ceil_mode, count_include_pad=count_include_pad) elif in_dim == 3: return nn.AvgPool3d(kernel_size=kernel_size, stride=stride) elif mode=='fractional_max': return nn.FractionalMaxPool2d(kernel_size=kernel_size, output_size=out_size, output_ratio=out_ratio, return_indices=return_indices, _random_samples=_random_samples) elif mode=='power': return nn.LPPool2d(norm_type=power, kernel_size=kernel_size, stride=stride, ceil_mode=ceil_mode) # normalization