Type Definition fann_sys::fann_callback_type[][src]

type fann_callback_type = Option<extern "C" fn(ann: *mut fann, train: *mut fann_train_data, max_epochs: c_uint, epochs_between_reports: c_uint, desired_error: c_float, epochs: c_uint) -> c_int>;

This callback function can be called during training when using fann_train_on_data, fann_train_on_file or fann_cascadetrain_on_data.

The callback can be set by using fann_set_callback and is very useful for doing custom things during training. It is recommended to use this function when implementing custom training procedures, or when visualizing the training in a GUI etc. The parameters which the callback function takes are the parameters given to fann_train_on_data, plus an epochs parameter which tells how many epochs the training has taken so far.

The callback function should return an integer, if the callback function returns -1, the training will terminate.

Example of a callback function:

extern crate libc;
extern crate fann_sys;

use libc::*;
use fann_sys::*;

extern "C" fn cb(ann: *mut fann,
                 train: *mut fann_train_data,
                 max_epochs: c_uint,
                 epochs_between_reports: c_uint,
                 desired_error: c_float,
                 epochs: c_uint) -> c_int {
    let mut mse = unsafe { fann_get_MSE(ann) };
    println!("Epochs: {}. MSE: {}. Desired MSE: {}", epochs, mse, desired_error);
    0
}

fn main() {
    let test_callback: fann_callback_type = Some(cb);
}