Unfold

class dragon.vm.torch.nn.Unfold(
  kernel_size,
  dilation=1,
  padding=0,
  stride=1
)[source]

Extract the sliding blocks.

This module excepts the input size \((N, C, D1, D2, ...)\), and output size is \((N, C \times \prod(\text{kernel\_size}), L)\), where \(N\) is the batch size, \(C\) is the number of channels, \(L\) is \(\prod(D_{\text{out}})\).

Examples:

m = torch.nn.Unfold(3, padding=1)
x = torch.ones(2, 2, 2, 2)
y = m(x)

__init__

Unfold.__init__(
  kernel_size,
  dilation=1,
  padding=0,
  stride=1
)[source]

Create a Unfold module.

Parameters:
  • kernel_size (Union[int, Sequence[int]]) – The size of sliding window.
  • dilation (Union[int, Sequence[int]], optional, default=1) – The dilated rate of sliding convolution.
  • stride (Union[int, Sequence[int]], optional, default=1) – The stride of sliding window.
  • padding (Union[int, Sequence[int]], optional, default=0) – The zero padding size.