pub struct Conv2d<D: Dtype, IT, OT, const RANK: usize> {
pub in_channels: usize,
pub out_channels: usize,
pub kernel_h: usize,
pub kernel_w: usize,
pub stride_h: usize,
pub stride_w: usize,
pub padding_h: usize,
pub padding_w: usize,
pub groups: usize,
pub has_bias: bool,
/* private fields */
}Expand description
2-D convolution layer: output = conv2d(input, weight) [+ b]
Input shape: [N, C_in, H_in, W_in ]
Output shape: [N, C_out, H_out, W_out]
where:
H_out = (H_in + 2*padding_h - kernel_h) / stride_h + 1
W_out = (W_in + 2*padding_w - kernel_w) / stride_w + 1
Type parameters:
D— element dtypeIT— input tensor type (rank 4:[N, C_in, H, W])OT— output tensor type (rank 4:[N, C_out, H, W])RANK— tensor rank; must be 4 for a valid 2-D convolution
Tensor bounds are on impls, not the struct, so SymTensor can have its
own Layer impl without a coherence conflict.
Fields§
§in_channels: usizeNumber of input channels.
out_channels: usizeNumber of output channels.
kernel_h: usizeConvolution kernel height.
kernel_w: usizeConvolution kernel width.
stride_h: usizeVertical stride.
stride_w: usizeHorizontal stride.
padding_h: usizeVertical zero-padding.
padding_w: usizeHorizontal zero-padding.
groups: usizeNumber of blocked/grouped connections (1 = standard convolution).
has_bias: boolWhether to add a learned bias.
Implementations§
Source§impl<D: Dtype, IT, OT, const RANK: usize> Conv2d<D, IT, OT, RANK>
impl<D: Dtype, IT, OT, const RANK: usize> Conv2d<D, IT, OT, RANK>
Sourcepub fn new(
in_channels: usize,
out_channels: usize,
kernel_size: (usize, usize),
stride: (usize, usize),
padding: (usize, usize),
has_bias: bool,
) -> Self
pub fn new( in_channels: usize, out_channels: usize, kernel_size: (usize, usize), stride: (usize, usize), padding: (usize, usize), has_bias: bool, ) -> Self
Create a new Conv2d layer.
kernel_size—(height, width)of the convolution kernelstride—(height, width)step between kernel applicationspadding—(height, width)zero-padding added to each spatial side
Trait Implementations§
Auto Trait Implementations§
impl<D, IT, OT, const RANK: usize> Freeze for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> RefUnwindSafe for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Send for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Sync for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> Unpin for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> UnsafeUnpin for Conv2d<D, IT, OT, RANK>
impl<D, IT, OT, const RANK: usize> UnwindSafe for Conv2d<D, IT, OT, RANK>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more