Struct rustml::opt::OptParams
[−]
[src]
pub struct OptParams<T: Clone> { pub alpha: Option<T>, pub iter: Option<usize>, pub eps: Option<T>, }
Creates a container that holds the parameters for an optimization algorithm.
Fields
alpha | learning rate |
iter | number of iterations |
eps | stopping criterion |
Methods
impl<T: Clone> OptParams<T>
fn new() -> OptParams<T>
Creates a new container with no parameters.
Example
use rustml::opt::*; let opts = OptParams::<f64>::new(); assert!(opts.alpha.is_none());
fn alpha(&self, val: T) -> OptParams<T>
Sets the learning rate.
Example
use rustml::opt::*; let opts = empty_opts().alpha(0.2); assert_eq!(opts.alpha.unwrap(), 0.2);
fn iter(&self, val: usize) -> OptParams<T>
Sets the maximum number of iterations.
Example
use rustml::opt::*; let opts = empty_opts().iter(100); assert_eq!(opts.iter.unwrap(), 100);
fn eps(&self, val: T) -> OptParams<T>
Sets the stopping criterion.
Example
use rustml::opt::*; let opts = empty_opts().eps(0.01); assert_eq!(opts.eps.unwrap(), 0.01);