pub struct Sequential { /* private fields */ }Expand description
Sequential container for chaining modules.
Modules are executed in order, with each module’s output becoming the next module’s input.
§Example
ⓘ
use aprender::nn::{Sequential, Linear, ReLU, Dropout};
let model = Sequential::new()
.add(Linear::new(784, 256))
.add(ReLU::new())
.add(Dropout::new(0.5))
.add(Linear::new(256, 10));
let x = Tensor::randn(&[32, 784]);
let output = model.forward(&x); // [32, 10]Implementations§
Trait Implementations§
Source§impl Debug for Sequential
impl Debug for Sequential
Source§impl Default for Sequential
impl Default for Sequential
Source§impl Module for Sequential
impl Module for Sequential
Source§fn parameters_mut(&mut self) -> Vec<&mut Tensor>
fn parameters_mut(&mut self) -> Vec<&mut Tensor>
Get mutable references to all learnable parameters. Read more
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the number of learnable parameters.
Auto Trait Implementations§
impl Freeze for Sequential
impl !RefUnwindSafe for Sequential
impl Send for Sequential
impl Sync for Sequential
impl Unpin for Sequential
impl !UnwindSafe for Sequential
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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