Struct fann::FannTrainer

source ·
pub struct FannTrainer<'a> { /* private fields */ }
Expand description

A training configuration. Create this with Fann::on_data or Fann::on_file and run the training with train.

Implementations§

source§

impl<'a> FannTrainer<'a>

source

pub fn with_reports(self, interval: c_uint) -> FannTrainer<'a>

Activates printing reports periodically. Between two reports, interval neurons are added (for cascade training) or training goes on for interval epochs (otherwise).

source

pub fn with_callback( self, interval: c_uint, callback: &'a dyn Fn(&Fann, &TrainData, c_uint) -> CallbackResult ) -> FannTrainer<'a>

Configures a callback to be called periodically during training. Every interval epochs (for regular training) or every time interval new neurons have been added (for cascade training), the callback runs. It receives as arguments:

  • a reference to the current Fann,
  • a reference to the training data,
  • the number of steps (added neurons or epochs) taken so far.
source

pub fn cascade(self) -> FannTrainer<'a>

Use the Cascade2 algorithm: This adds neurons to the neural network while training, starting with an ANN without any hidden layers. The network should use shortcut connections, so it needs to be created like this:

let td = fann::TrainData::from_file("test_files/xor.data").unwrap();
let fann = fann::Fann::new_shortcut(&[td.num_input(), td.num_output()]).unwrap();
source

pub fn train( &mut self, max_steps: c_uint, desired_error: c_float ) -> FannResult<()>

Train the network until either the mean square error drops below the desired_error, or the maximum number of steps is reached. If cascade training is activated, max_steps refers to the number of neurons that are added, otherwise it is the maximum number of training epochs.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FannTrainer<'a>

§

impl<'a> !Send for FannTrainer<'a>

§

impl<'a> !Sync for FannTrainer<'a>

§

impl<'a> Unpin for FannTrainer<'a>

§

impl<'a> !UnwindSafe for FannTrainer<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.