pub struct Conv2d {
pub weight: Matrix,
pub bias: Option<Vec<f32>>,
pub in_channels: usize,
pub kernel: usize,
pub stride: usize,
pub padding: usize,
}Expand description
A two-dimensional convolution with zero padding.
Fields§
§weight: Matrix[out_channels, in_channels * kernel * kernel], the layout a
checkpoint’s [out, in, kh, kw] tensor already has once flattened.
bias: Option<Vec<f32>>§in_channels: usize§kernel: usize§stride: usize§padding: usizeImplementations§
Source§impl Conv2d
impl Conv2d
Sourcepub fn new(
weight: Matrix,
bias: Option<Vec<f32>>,
in_channels: usize,
kernel: usize,
stride: usize,
padding: usize,
) -> Result<Self, NetworkError>
pub fn new( weight: Matrix, bias: Option<Vec<f32>>, in_channels: usize, kernel: usize, stride: usize, padding: usize, ) -> Result<Self, NetworkError>
Wraps weights read from a checkpoint.
weight is the [out_channels, in_channels * kernel * kernel] matrix a
[out, in, kh, kw] tensor flattens to, which is what
crate::safetensors::SafeTensors::tensor hands back.
Sourcepub fn out_channels(&self) -> usize
pub fn out_channels(&self) -> usize
Output channels.
Sourcepub fn output_size(&self, height: usize, width: usize) -> (usize, usize)
pub fn output_size(&self, height: usize, width: usize) -> (usize, usize)
The output shape for an input of the given size.
Sourcepub fn forward(&self, input: &FeatureMap) -> Result<FeatureMap, NetworkError>
pub fn forward(&self, input: &FeatureMap) -> Result<FeatureMap, NetworkError>
Convolves input.
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
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