pub struct Linear { /* private fields */ }Expand description
Linear (Fully Connected) layer.
Performs the operation: output = input @ weight^T + bias
Implementations§
Source§impl Linear
impl Linear
Sourcepub fn new(
in_features: usize,
out_features: usize,
use_bias: bool,
) -> CnnResult<Self>
pub fn new( in_features: usize, out_features: usize, use_bias: bool, ) -> CnnResult<Self>
Creates a new Linear layer with zero-initialized weights.
Sourcepub fn with_weights(
in_features: usize,
out_features: usize,
weight: Vec<f32>,
bias: Option<Vec<f32>>,
) -> CnnResult<Self>
pub fn with_weights( in_features: usize, out_features: usize, weight: Vec<f32>, bias: Option<Vec<f32>>, ) -> CnnResult<Self>
Creates a Linear layer with provided weights.
Sourcepub fn in_features(&self) -> usize
pub fn in_features(&self) -> usize
Returns the input features.
Sourcepub fn out_features(&self) -> usize
pub fn out_features(&self) -> usize
Returns the output features.
Source§impl Linear
impl Linear
Sourcepub fn output_shape(&self, input_shape: &TensorShape) -> TensorShape
pub fn output_shape(&self, input_shape: &TensorShape) -> TensorShape
Returns the output TensorShape for a given input TensorShape
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Linear
impl RefUnwindSafe for Linear
impl Send for Linear
impl Sync for Linear
impl Unpin for Linear
impl UnsafeUnpin for Linear
impl UnwindSafe for Linear
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