pub struct TrainData { /* private fields */ }
Implementations§
source§impl TrainData
impl TrainData
sourcepub fn from_file<P: AsRef<Path>>(path: P) -> FannResult<TrainData>
pub fn from_file<P: AsRef<Path>>(path: P) -> FannResult<TrainData>
Read a file that stores training data.
The file must be formatted like:
num_train_data num_input num_output
inputdata separated by space
outputdata separated by space
.
.
.
inputdata separated by space
outputdata separated by space
sourcepub fn from_callback(
num_data: c_uint,
num_input: c_uint,
num_output: c_uint,
cb: Box<dyn Fn(c_uint) -> (Vec<fann_type>, Vec<fann_type>)>
) -> FannResult<TrainData>
pub fn from_callback( num_data: c_uint, num_input: c_uint, num_output: c_uint, cb: Box<dyn Fn(c_uint) -> (Vec<fann_type>, Vec<fann_type>)> ) -> FannResult<TrainData>
Create training data using the given callback which for each number between 0
(included)
and num_data
(excluded) returns a pair of input and output vectors with num_input
and
num_output
entries respectively.
sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> FannResult<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> FannResult<()>
Save the training data to a file.
sourcepub fn merge(data1: &TrainData, data2: &TrainData) -> FannResult<TrainData>
pub fn merge(data1: &TrainData, data2: &TrainData) -> FannResult<TrainData>
Merge the given data sets into a new one.
sourcepub fn subset(&self, pos: c_uint, length: c_uint) -> FannResult<TrainData>
pub fn subset(&self, pos: c_uint, length: c_uint) -> FannResult<TrainData>
Create a subset of the training data, starting at the given positon and consisting of
length
samples.
sourcepub fn num_output(&self) -> c_uint
pub fn num_output(&self) -> c_uint
Return the number of output values in each training pattern.
sourcepub fn scale_for(&mut self, fann: &Fann) -> FannResult<()>
pub fn scale_for(&mut self, fann: &Fann) -> FannResult<()>
Scale input and output in the training data using the parameters previously calculated for the given network.
sourcepub fn descale_for(&mut self, fann: &Fann) -> FannResult<()>
pub fn descale_for(&mut self, fann: &Fann) -> FannResult<()>
Descale input and output in the training data using the parameters previously calculated for the given network.
sourcepub fn scale_input(
&mut self,
new_min: fann_type,
new_max: fann_type
) -> FannResult<()>
pub fn scale_input( &mut self, new_min: fann_type, new_max: fann_type ) -> FannResult<()>
Scales the inputs in the training data to the specified range.
sourcepub fn scale_output(
&mut self,
new_min: fann_type,
new_max: fann_type
) -> FannResult<()>
pub fn scale_output( &mut self, new_min: fann_type, new_max: fann_type ) -> FannResult<()>
Scales the outputs in the training data to the specified range.
sourcepub fn scale(
&mut self,
new_min: fann_type,
new_max: fann_type
) -> FannResult<()>
pub fn scale( &mut self, new_min: fann_type, new_max: fann_type ) -> FannResult<()>
Scales the inputs and outputs in the training data to the specified range.
sourcepub fn shuffle(&mut self)
pub fn shuffle(&mut self)
Shuffle training data, randomizing the order. This is recommended for incremental training while it does not affect batch training.
sourcepub unsafe fn get_raw(&self) -> *mut fann_train_data
pub unsafe fn get_raw(&self) -> *mut fann_train_data
Get a pointer to the underlying raw fann_train_data
structure.