Struct neuronika::nn::Conv2d [−][src]
pub struct Conv2d<Pad: PaddingMode> {
pub padding: (usize, usize),
pub padding_mode: Pad,
pub stride: (usize, usize),
pub dilation: (usize, usize),
pub weight: Learnable<Ix4>,
pub bias: Learnable<Ix1>,
}
Expand description
Applies a spatial convolution over an input signal composed of several input planes.
See also GroupedConv2d
.
Fields
padding: (usize, usize)
padding_mode: Pad
stride: (usize, usize)
dilation: (usize, usize)
weight: Learnable<Ix4>
bias: Learnable<Ix1>
Implementations
Creates a new Conv2d.
Arguments
-
in_channels
- number of planes in the input signal. -
out_channels
- number of planes in the output signal. -
kernel_size
- size of the kernel, a 2-tuple for this two-dimensional case. -
padding
- padding to be applied to the input, a 2-tuple for this two-dimensional case. -
padding_mode
- padding mode, it can be:Zero
,Constant
,Reflective
orReplicative
. -
stride
- stride of the convolution, a 2-tuple for this two-dimensional case. -
dilation
- controls the spacing between the kernel points, a 2-tuple for this two-dimensional case.
The weight and the bias are initialized from U(-k, k) where
k = (1. /(in_channels * kernel_w * kernel_h) as f32).sqrt()
.
Computes a 2-dimensional convolution (cross correlation).
Arguments
input
- the signal to convolve.
The input must be of shape (N, Cin, H, W)
- N is the batch size
- Cin is the number of input channels
- H is the height of the input
- W is the width of the input
The kernel must be of shape (Cout, Cin, Hk, Wk)
- Cout is the number of output channels
- Cin is the number of input channels
- Hk is the height of the kernel
- Wk is the width of the kernel
The resulting output shape will be (N, Cout, Hout, Wout)
Trait Implementations
Registers the weight and the bias of this Conv2d
instance.
Register self
’s status to the model’s status state status
.