pub struct Sequential<B>where
B: Backend,{ /* private fields */ }Expand description
A container that chains modules sequentially.
Each module’s output becomes the next module’s input. Sequential itself implements Module, so it can be nested.
Implementations§
Source§impl<B> Sequential<B>where
B: Backend,
impl<B> Sequential<B>where
B: Backend,
Sourcepub fn new() -> Sequential<B>
pub fn new() -> Sequential<B>
Create an empty Sequential.
Sourcepub fn add<M>(self, module: M) -> Sequential<B>where
M: Module<B> + 'static,
pub fn add<M>(self, module: M) -> Sequential<B>where
M: Module<B> + 'static,
Add a layer to the end of the sequence. Returns self for chaining.
Trait Implementations§
Source§impl<B> Default for Sequential<B>where
B: Backend,
impl<B> Default for Sequential<B>where
B: Backend,
Source§fn default() -> Sequential<B>
fn default() -> Sequential<B>
Returns the “default value” for a type. Read more
Source§impl<B> Module<B> for Sequential<B>where
B: Backend,
impl<B> Module<B> for Sequential<B>where
B: Backend,
Source§fn set_training(&self, training: bool)
fn set_training(&self, training: bool)
Propagate training mode to all child layers.
Source§fn forward(&self, x: &Tensor<B>) -> Result<Tensor<B>, Error>
fn forward(&self, x: &Tensor<B>) -> Result<Tensor<B>, Error>
Compute the output tensor from the input tensor.
This defines the layer’s computation (forward pass).
Source§fn parameters(&self) -> Vec<Tensor<B>>
fn parameters(&self) -> Vec<Tensor<B>>
Return all trainable parameters of this module.
The optimizer uses these to update weights during training.
Source§fn named_parameters(&self) -> Vec<(String, Tensor<B>)>
fn named_parameters(&self) -> Vec<(String, Tensor<B>)>
Return all trainable parameters with human-readable names. Read more
Source§fn is_training(&self) -> bool
fn is_training(&self) -> bool
Whether the module is in training mode (default: true).
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Total number of scalar parameters in this module.
Source§fn trainable_params_count(&self) -> usize
fn trainable_params_count(&self) -> usize
Number of trainable (variable) parameters.
Auto Trait Implementations§
impl<B> Freeze for Sequential<B>
impl<B> !RefUnwindSafe for Sequential<B>
impl<B> !Send for Sequential<B>
impl<B> !Sync for Sequential<B>
impl<B> Unpin for Sequential<B>
impl<B> !UnwindSafe for Sequential<B>
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> 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