pub struct Hextral { /* private fields */ }Implementations§
Source§impl Hextral
impl Hextral
pub fn new( input_size: usize, hidden_sizes: &[usize], output_size: usize, activation: ActivationFunction, optimizer: Optimizer, ) -> Self
Sourcepub fn set_regularization(&mut self, reg: Regularization)
pub fn set_regularization(&mut self, reg: Regularization)
Set regularization
Sourcepub fn set_loss_function(&mut self, loss: LossFunction)
pub fn set_loss_function(&mut self, loss: LossFunction)
Set loss function
Sourcepub fn enable_batch_norm(&mut self)
pub fn enable_batch_norm(&mut self)
Enable batch normalization for all hidden layers
Sourcepub fn disable_batch_norm(&mut self)
pub fn disable_batch_norm(&mut self)
Disable batch normalization
Sourcepub fn set_training_mode(&mut self, training: bool)
pub fn set_training_mode(&mut self, training: bool)
Set training mode for batch normalization
pub async fn forward(&self, input: &DVector<f64>) -> DVector<f64>
pub async fn predict(&self, input: &DVector<f64>) -> DVector<f64>
pub async fn predict_batch(&self, inputs: &[DVector<f64>]) -> Vec<DVector<f64>> ⓘ
Sourcepub fn compute_loss(
&self,
prediction: &DVector<f64>,
target: &DVector<f64>,
) -> f64
pub fn compute_loss( &self, prediction: &DVector<f64>, target: &DVector<f64>, ) -> f64
Compute loss between prediction and target
Sourcepub fn compute_loss_gradient(
&self,
prediction: &DVector<f64>,
target: &DVector<f64>,
) -> DVector<f64>
pub fn compute_loss_gradient( &self, prediction: &DVector<f64>, target: &DVector<f64>, ) -> DVector<f64>
Compute loss gradient for backpropagation
pub async fn train_step( &mut self, input: &DVector<f64>, target: &DVector<f64>, learning_rate: f64, ) -> f64
Sourcepub async fn train(
&mut self,
train_inputs: &[DVector<f64>],
train_targets: &[DVector<f64>],
learning_rate: f64,
epochs: usize,
batch_size: Option<usize>,
val_inputs: Option<&[DVector<f64>]>,
val_targets: Option<&[DVector<f64>]>,
early_stopping: Option<EarlyStopping>,
checkpoint_config: Option<CheckpointConfig>,
) -> Result<(Vec<f64>, Vec<f64>), Box<dyn Error>>
pub async fn train( &mut self, train_inputs: &[DVector<f64>], train_targets: &[DVector<f64>], learning_rate: f64, epochs: usize, batch_size: Option<usize>, val_inputs: Option<&[DVector<f64>]>, val_targets: Option<&[DVector<f64>]>, early_stopping: Option<EarlyStopping>, checkpoint_config: Option<CheckpointConfig>, ) -> Result<(Vec<f64>, Vec<f64>), Box<dyn Error>>
Full async training method with early stopping and checkpoints
pub async fn evaluate( &self, test_inputs: &[DVector<f64>], test_targets: &[DVector<f64>], ) -> f64
Sourcepub fn parameter_count(&self) -> usize
pub fn parameter_count(&self) -> usize
Get the number of parameters in the network
Sourcepub fn architecture(&self) -> Vec<usize>
pub fn architecture(&self) -> Vec<usize>
Get network architecture info
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Hextral
impl<'de> Deserialize<'de> for Hextral
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Hextral
impl RefUnwindSafe for Hextral
impl Send for Hextral
impl Sync for Hextral
impl Unpin for Hextral
impl UnwindSafe for Hextral
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.