pub struct Conv2d { /* private fields */ }Expand description
2D Convolution Layer
Performs 2D convolution on NHWC tensors with configurable:
- Kernel size
- Stride
- Padding
- Groups (for depthwise and grouped convolutions)
Kernel layout: [out_channels, kernel_h, kernel_w, in_channels] (OHWI)
Implementations§
Source§impl Conv2d
impl Conv2d
Sourcepub fn new(
in_channels: usize,
out_channels: usize,
kernel_size: usize,
stride: usize,
padding: usize,
) -> Self
pub fn new( in_channels: usize, out_channels: usize, kernel_size: usize, stride: usize, padding: usize, ) -> Self
Create a new Conv2d layer with Xavier initialization
Sourcepub fn builder(
in_channels: usize,
out_channels: usize,
kernel_size: usize,
) -> Conv2dBuilder
pub fn builder( in_channels: usize, out_channels: usize, kernel_size: usize, ) -> Conv2dBuilder
Create a Conv2d builder
Sourcepub fn with_bias(
in_channels: usize,
out_channels: usize,
kernel_size: usize,
stride: usize,
padding: usize,
) -> Self
pub fn with_bias( in_channels: usize, out_channels: usize, kernel_size: usize, stride: usize, padding: usize, ) -> Self
Create Conv2d with bias
Sourcepub fn output_shape_nchw(&self, input_shape: &TensorShape) -> TensorShape
pub fn output_shape_nchw(&self, input_shape: &TensorShape) -> TensorShape
Get the output shape for a TensorShape input (NCHW format)
Sourcepub fn output_shape(&self, input_shape: &[usize]) -> CnnResult<Vec<usize>>
pub fn output_shape(&self, input_shape: &[usize]) -> CnnResult<Vec<usize>>
Get the output shape for a given input shape
Sourcepub fn kernel_size(&self) -> usize
pub fn kernel_size(&self) -> usize
Get the kernel size
Sourcepub fn out_channels(&self) -> usize
pub fn out_channels(&self) -> usize
Get the number of output channels
Sourcepub fn in_channels(&self) -> usize
pub fn in_channels(&self) -> usize
Get the number of input channels
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Conv2d
impl RefUnwindSafe for Conv2d
impl Send for Conv2d
impl Sync for Conv2d
impl Unpin for Conv2d
impl UnsafeUnpin for Conv2d
impl UnwindSafe for Conv2d
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