pub struct Flatten;Expand description
Flattens the input tensor into a 2D tensor (batch_size, remaining_features).
Assumes the first dimension is the batch dimension and flattens all subsequent dimensions. Input shape: (B, D1, D2, …) Output shape: (B, D1 * D2 * …)
Implementations§
Trait Implementations§
Source§impl Module for Flatten
impl Module for Flatten
fn forward(&self, x: &Tensor) -> Tensor
fn parameters(&self) -> Vec<Tensor> ⓘ
fn state_dict(&self) -> StateDict
fn load_state_dict(&mut self, _state: &StateDict)
fn zero_grad(&mut self)
Source§fn to_device(&mut self, device: Device)
fn to_device(&mut self, device: Device)
Move all module parameters to a specific device Read more
Source§fn train(&mut self, _mode: bool)
fn train(&mut self, _mode: bool)
Switch between training and evaluation modes.
Important for layers like
BatchNorm and Dropout.fn eval(&mut self)
Auto Trait Implementations§
impl Freeze for Flatten
impl RefUnwindSafe for Flatten
impl Send for Flatten
impl Sync for Flatten
impl Unpin for Flatten
impl UnwindSafe for Flatten
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