pub struct Prodigy { /* private fields */ }Expand description
Prodigy optimizer (Adaptive Learning Rate Method)
Prodigy automatically tunes the learning rate without manual tuning. Just use lr=1.0 for almost any problem!
Implementations§
Source§impl Prodigy
impl Prodigy
Sourcepub fn new(
params: Vec<Arc<RwLock<Tensor>>>,
lr: f32,
beta1: f32,
beta2: f32,
weight_decay: f32,
) -> Self
pub fn new( params: Vec<Arc<RwLock<Tensor>>>, lr: f32, beta1: f32, beta2: f32, weight_decay: f32, ) -> Self
Create a new Prodigy optimizer
§Arguments
params- Parameters to optimizelr- Learning rate (use 1.0 for most problems!)beta1- Momentum coefficient (default: 0.9)beta2- Variance coefficient (default: 0.999)weight_decay- Weight decay coefficient (default: 0.0)
§Example
use torsh_optim::prelude::Prodigy;
use parking_lot::RwLock;
use std::sync::Arc;
let param = Arc::new(RwLock::new(randn::<f32>(&[100, 100])?));
let params = vec![param];
// Use lr=1.0 - it adapts automatically!
let optimizer = Prodigy::new(params, 1.0, 0.9, 0.999, 0.0);Sourcepub fn from_config(
params: Vec<Arc<RwLock<Tensor>>>,
config: ProdigyConfig,
) -> Self
pub fn from_config( params: Vec<Arc<RwLock<Tensor>>>, config: ProdigyConfig, ) -> Self
Create from configuration
Sourcepub fn builder() -> ProdigyBuilder
pub fn builder() -> ProdigyBuilder
Builder for Prodigy optimizer
Sourcepub fn get_effective_lr(&self) -> f32
pub fn get_effective_lr(&self) -> f32
Get effective learning rate
Trait Implementations§
Source§impl Optimizer for Prodigy
impl Optimizer for Prodigy
Source§fn step(&mut self) -> OptimizerResult<()>
fn step(&mut self) -> OptimizerResult<()>
Perform a single optimization step
Source§fn add_param_group(
&mut self,
params: Vec<Arc<RwLock<Tensor>>>,
options: HashMap<String, f32>,
)
fn add_param_group( &mut self, params: Vec<Arc<RwLock<Tensor>>>, options: HashMap<String, f32>, )
Add a parameter group
Source§fn parameters(&self) -> Vec<Arc<RwLock<Tensor>>>
fn parameters(&self) -> Vec<Arc<RwLock<Tensor>>>
Get the parameter tensors managed by this optimizer. Read more
Source§fn state_dict(&self) -> OptimizerResult<OptimizerState>
fn state_dict(&self) -> OptimizerResult<OptimizerState>
Get state dict for serialization
Source§fn load_state_dict(&mut self, state: OptimizerState) -> OptimizerResult<()>
fn load_state_dict(&mut self, state: OptimizerState) -> OptimizerResult<()>
Load state dict
Auto Trait Implementations§
impl !RefUnwindSafe for Prodigy
impl !UnwindSafe for Prodigy
impl Freeze for Prodigy
impl Send for Prodigy
impl Sync for Prodigy
impl Unpin for Prodigy
impl UnsafeUnpin for Prodigy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<O> OptimizerExt for Owhere
O: Optimizer,
impl<O> OptimizerExt for Owhere
O: Optimizer,
Source§fn distributed(
self,
config: DistributedConfig,
) -> OptimizerResult<DistributedOptimizer<Self>>
fn distributed( self, config: DistributedConfig, ) -> OptimizerResult<DistributedOptimizer<Self>>
Wrap this optimizer with distributed functionality