Skip to main content

fold4d

Function fold4d 

Source
pub fn fold4d(
    x: Tensor<3>,
    output_size: [usize; 2],
    kernel_size: [usize; 2],
    options: UnfoldOptions,
) -> Tensor<4>
Expand description

Applies a 3D to 4D fold, the inverse of unfold4d.

Combines an array of sliding local blocks into a large containing tensor, summing the values of blocks that overlap. This is the operation performed by torch.nn.Fold, and is the adjoint of unfold4d: it reuses the same one-hot kernel through a conv_transpose2d.

§Arguments

  • x - Input columns of shape [batch_size, channels * kernel_size_0 * kernel_size_1, number_of_blocks].
  • output_size - The spatial size [height, width] of the folded output tensor.
  • kernel_size - The size of the sliding blocks.
  • options - The stride, padding and dilation of the matching unfold.

§Returns

A tensor of shape [batch_size, channels, output_size_0, output_size_1].