array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'function.fann-create-train-from-callback.php', 1 => 'fann_create_train_from_callback', 2 => 'Creates the training data struct from a user supplied function', ), 'up' => array ( 0 => 'ref.fann.php', 1 => 'Fann Funzioni', ), 'prev' => array ( 0 => 'function.fann-create-train.php', 1 => 'fann_create_train', ), 'next' => array ( 0 => 'function.fann-descale-input.php', 1 => 'fann_descale_input', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/fann/functions/fann-create-train-from-callback.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PECL fann >= 1.0.0)
fann_create_train_from_callback — Creates the training data struct from a user supplied function
$num_data,$num_input,$num_output,$user_functionCreates the training data struct from a user supplied function. As the training data are numerable (data 1, data 2...), the user must write a function that receives the number of the training data set (input, output) and returns the set.
num_dataThe number of training data
num_inputThe number of inputs per training data
num_outputThe number of ouputs per training data
user_functionThe user supplied function with following parameters:
num - The number of the training data setnum_input - The number of inputs per training datanum_output - The number of ouputs per training data
The function should return an associative array with keys input and output and
two array values of input and output.
Example #1 fann_create_train_from_callback() example
<?php
function create_train_callback($num_data, $num_input, $num_output) {
return array(
"input" => array_fill(0, $num_input, 1),
"output" => array_fill(0, $num_output, 1),
);
}
$num_data = 3;
$num_input = 2;
$num_output = 1;
$train_data = fann_create_train_from_callback($num_data, $num_input, $num_output, "create_train_callback");
if ($train_data) {
// Do something with $train_data
}
?>Nota:
This function is only available if the fann extension has been build against libfann >= 2.2.