pub struct LinearStochasticDepth {
pub num_layers: usize,
pub drop_prob_min: f64,
pub drop_prob_max: f64,
}Expand description
Linear stochastic depth scheduler.
Linearly increases drop probability from min to max across network depth. This is the standard approach used in most deep networks:
- Shallow layers: low drop probability (more stable)
- Deep layers: high drop probability (more regularization)
§Example
use tensorlogic_train::LinearStochasticDepth;
// 10 layers, drop_prob from 0.0 to 0.3
let scheduler = LinearStochasticDepth::new(10, 0.0, 0.3).unwrap();
// Get drop probability for layer 5
let drop_prob_5 = scheduler.get_drop_prob(5);
assert!((drop_prob_5 - 0.15).abs() < 1e-6); // Halfway pointFields§
§num_layers: usizeTotal number of layers/blocks.
drop_prob_min: f64Minimum drop probability (first layer).
drop_prob_max: f64Maximum drop probability (last layer).
Implementations§
Source§impl LinearStochasticDepth
impl LinearStochasticDepth
Sourcepub fn get_drop_prob(&self, layer_idx: usize) -> f64
pub fn get_drop_prob(&self, layer_idx: usize) -> f64
Sourcepub fn create_drop_paths(&self) -> TrainResult<Vec<DropPath>>
pub fn create_drop_paths(&self) -> TrainResult<Vec<DropPath>>
Create DropPath instances for all layers.
§Returns
Vector of DropPath instances with linearly increasing drop probabilities.
Trait Implementations§
Source§impl Clone for LinearStochasticDepth
impl Clone for LinearStochasticDepth
Source§fn clone(&self) -> LinearStochasticDepth
fn clone(&self) -> LinearStochasticDepth
Returns a duplicate of the value. Read more
1.0.0 · 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 LinearStochasticDepth
impl RefUnwindSafe for LinearStochasticDepth
impl Send for LinearStochasticDepth
impl Sync for LinearStochasticDepth
impl Unpin for LinearStochasticDepth
impl UnwindSafe for LinearStochasticDepth
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