oneflow.nn.MaxUnpool3d¶
-
class
oneflow.nn.
MaxUnpool3d
(kernel_size: Union[int, Tuple[int, int, int]], stride: Optional[Union[int, Tuple[int, int, int]]] = None, padding: Optional[Union[int, Tuple[int, int, int]]] = 0)¶ Computes a partial inverse of
MaxPool3d
.MaxPool3d
is not fully invertible, since the non-maximal values are lost.MaxUnpool3d
takes in as input the output ofMaxPool3d
including the indices of the maximal values and computes a partial inverse in which all non-maximal values are set to zero.The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.nn.MaxPool3d.html.
Note
MaxPool3d
can map several input sizes to the same output sizes. Hence, the inversion process can get ambiguous. To accommodate this, you can provide the needed output size as an additional argumentoutput_size
in the forward call. See the Inputs section below.- Parameters
kernel_size (int or tuple) – Size of the max pooling window.
stride (int or tuple) – Stride of the max pooling window. It is set to
kernel_size
by default.padding (int or tuple) – Padding that was added to the input
- Inputs:
input: the input Tensor to invert
indices: the indices given out by
MaxPool3d
output_size (optional): the targeted output size
- Shape:
Input: \((N, C, D_{in}, H_{in}, W_{in})\).
Output: \((N, C, D_{out}, H_{out}, W_{out})\), where
\[D_{out} = (D_{in} - 1) \times \text{stride[0]} - 2 \times \text{padding[0]} + \text{kernel\_size[0]}\]\[H_{out} = (H_{in} - 1) \times \text{stride[1]} - 2 \times \text{padding[1]} + \text{kernel\_size[1]}\]\[W_{out} = (W_{in} - 1) \times \text{stride[2]} - 2 \times \text{padding[2]} + \text{kernel\_size[2]}\]or as given by
output_size
in the call operator
For example:
>>> import oneflow as flow >>> # pool of square window of size=3, stride=2 >>> pool = flow.nn.MaxPool3d(3, stride=2, return_indices=True) >>> unpool = flow.nn.MaxUnpool3d(3, stride=2) >>> output, indices = pool(flow.randn(20, 16, 51, 33, 15)) >>> unpooled_output = unpool(output, indices) >>> unpooled_output.size() oneflow.Size([20, 16, 51, 33, 15])
Note
When indices contains elements out of the output_size range, an RuntimeError will be raised on the cpu and an indeterminate result will be calculated on the cuda.