pub struct Conv1DLayer {
pub in_channels: usize,
pub out_channels: usize,
pub kernel_size: usize,
pub weights: Vec<Vec<Vec<f64>>>,
pub biases: Vec<f64>,
pub activation: ExtActivation,
}Expand description
A 1-D convolutional layer operating on a sequence of feature vectors.
Applies a set of out_channels filters, each of length kernel_size
spanning in_channels input channels, using causal (left) padding so the
output length equals the input length.
Layout:
weights[o][k][c]= weight for output channelo, kernel positionk, input channelc.biases[o]= bias for output channelo.
Fields§
§in_channels: usizeNumber of input channels per time step.
out_channels: usizeNumber of output channels per time step.
kernel_size: usizeKernel (filter) length along the time axis.
weights: Vec<Vec<Vec<f64>>>Filter weights: weights[out_ch][kernel_pos][in_ch].
biases: Vec<f64>Bias per output channel.
activation: ExtActivationActivation function applied after convolution.
Implementations§
Source§impl Conv1DLayer
impl Conv1DLayer
Sourcepub fn new(
in_channels: usize,
out_channels: usize,
kernel_size: usize,
activation: ExtActivation,
) -> Self
pub fn new( in_channels: usize, out_channels: usize, kernel_size: usize, activation: ExtActivation, ) -> Self
Create a new Conv1D layer with zero-initialised weights.
Sourcepub fn forward(&self, input: &[Vec<f64>]) -> Vec<Vec<f64>>
pub fn forward(&self, input: &[Vec<f64>]) -> Vec<Vec<f64>>
Forward pass.
input has shape [seq_len][in_channels]. Returns a tensor of shape
[seq_len][out_channels] using causal (left-zero) padding.
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Total number of trainable parameters.
Trait Implementations§
Source§impl Clone for Conv1DLayer
impl Clone for Conv1DLayer
Source§fn clone(&self) -> Conv1DLayer
fn clone(&self) -> Conv1DLayer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Conv1DLayer
impl RefUnwindSafe for Conv1DLayer
impl Send for Conv1DLayer
impl Sync for Conv1DLayer
impl Unpin for Conv1DLayer
impl UnsafeUnpin for Conv1DLayer
impl UnwindSafe for Conv1DLayer
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