nn.conv
The convolution operator consumes an input tensor and a filter (input weight tensor), and computes the output.
Args
X
(@Tensor<T>
) - Input data tensor, has size (N x C x H x W), where N is the batch size, C is the number of channels, and H and W if 2D, otherwise the size is (N x C x D1 x D2 ... x Dn).W
(@Tensor<T>
) - The weight tensor, has size (C x M/group x kH x kW), where C is the number of channels, and kH and kW are the height and width of the kernel, and M is the number of feature maps if 2D, for more than 2 dimensions, the weight shape will be (C x M/group x k1 x k2 x ... x kn).B
(Option<@Tensor<T>>
) - Optional 1D bias to be added to the convolution, has size of M.auto_pad
(Option<AUTO_PAD>
) - Default is NOTSET, auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. NOTSET means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so thatoutput_shape[i] = ceil(input_shape[i] / strides[i])
for each axisi
.dilations
(Option<Span<usize>>
) - Dilation value along each spatial axis of the filter. If not present, the dilation defaults to 1 along each spatial axis.group
(Option<usize>
) - Default is 1, number of groups input channels and output channels are divided into.kernel_shape
(Option<Span<usize>>
) - The shape of the convolution kernel. If not present, should be inferred from input W.pads
(Option<Span<usize>>
) - Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis.pads
format should be as follow [x1_begin, x2_begin...x1_end, x2_end,...], where xi_begin the number of pixels added at the beginning of axisi
and xi_end, the number of pixels added at the end of axisi
. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.strides
(Option<Span<usize>>
) - Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.
Returns
A Tensor<T>
that contains the result of the convolution.
Examples
Last updated