pub struct Conv2dLayer { /* private fields */ }Expand description
2D convolution layer (NHWC layout).
Supports both inference-mode (raw tensor) and graph-mode (autograd training).
Kernel shape: [KH, KW, C_in, C_out].
Implementations§
Source§impl Conv2dLayer
impl Conv2dLayer
pub fn new( in_channels: usize, out_channels: usize, kernel_h: usize, kernel_w: usize, stride_h: usize, stride_w: usize, weight: Tensor, bias: Option<Tensor>, ) -> Result<Self, ModelError>
Sourcepub fn new_in_graph(
graph: &mut Graph,
in_channels: usize,
out_channels: usize,
kernel_h: usize,
kernel_w: usize,
stride_h: usize,
stride_w: usize,
weight: Tensor,
bias: Option<Tensor>,
) -> Result<Self, ModelError>
pub fn new_in_graph( graph: &mut Graph, in_channels: usize, out_channels: usize, kernel_h: usize, kernel_w: usize, stride_h: usize, stride_w: usize, weight: Tensor, bias: Option<Tensor>, ) -> Result<Self, ModelError>
Creates a conv2d layer and registers its parameters as graph variables.
pub fn zero_init( in_channels: usize, out_channels: usize, kernel_h: usize, kernel_w: usize, stride_h: usize, stride_w: usize, use_bias: bool, ) -> Result<Self, ModelError>
Sourcepub fn register_params(&mut self, graph: &mut Graph)
pub fn register_params(&mut self, graph: &mut Graph)
Registers weight/bias tensors as graph variables for autograd training.
Sourcepub fn sync_from_graph(&mut self, graph: &Graph) -> Result<(), ModelError>
pub fn sync_from_graph(&mut self, graph: &Graph) -> Result<(), ModelError>
Synchronizes owned tensors from the graph (e.g. after optimizer step).
pub fn in_channels(&self) -> usize
pub fn out_channels(&self) -> usize
pub fn kernel_h(&self) -> usize
pub fn kernel_w(&self) -> usize
pub fn stride_h(&self) -> usize
pub fn stride_w(&self) -> usize
pub fn weight(&self) -> &Tensor
pub fn bias(&self) -> Option<&Tensor>
pub fn weight_mut(&mut self) -> &mut Tensor
pub fn bias_mut(&mut self) -> Option<&mut Tensor>
pub fn weight_node(&self) -> Option<NodeId>
pub fn bias_node(&self) -> Option<NodeId>
pub fn forward( &self, graph: &mut Graph, input: NodeId, ) -> Result<NodeId, ModelError>
pub fn forward_inference(&self, input: &Tensor) -> Result<Tensor, ModelError>
Trait Implementations§
Source§impl Clone for Conv2dLayer
impl Clone for Conv2dLayer
Source§fn clone(&self) -> Conv2dLayer
fn clone(&self) -> Conv2dLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Conv2dLayer
impl Debug for Conv2dLayer
Source§impl PartialEq for Conv2dLayer
impl PartialEq for Conv2dLayer
impl StructuralPartialEq for Conv2dLayer
Auto Trait Implementations§
impl Freeze for Conv2dLayer
impl RefUnwindSafe for Conv2dLayer
impl Send for Conv2dLayer
impl Sync for Conv2dLayer
impl Unpin for Conv2dLayer
impl UnsafeUnpin for Conv2dLayer
impl UnwindSafe for Conv2dLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more