(PECL fann >= 1.0.0)

fann_subset_train_dataReturns an copy of a subset of the train data


resource fann_subset_train_data ( resource $data , int $pos , int $length )

Returns an copy of a subset of the train data resource, starting at position pos and length elements forward.

The fann_subset_train_data(train_data, 0, fann_length_train_data(train_data)) do the same as fann_duplicate_train_data()



Neural network training data resource.


Starting position.


The number of copied elements.

Значення, що повертаються

Returns a train data resource on success, or FALSE on error.

Прогляньте Також

add a note add a note

User Contributed Notes 1 note

geekgirl dot joy at gmail dot com
3 years ago
// Use this code to split your data into smaller sets.
// Useful for splitting your training data into training and testing groups

// Load Data
$data_file = "";
$train_data = fann_read_train_from_file(dirname(__FILE__)  .  DIRECTORY_SEPARATOR  $data_file);

// Calculate how many examples are in the first group
$total_length = fann_length_train_data($train_data);
$a_length = floor($total_length / 10);

// Split the subsets
$training_data_a  = fann_subset_train_data($train_data, 0, $a_length);
$training_data_b  = fann_subset_train_data($train_data, $a_length, $total_length-$a_length);

// Save the training data to separate files
fann_save_train ($training_data_a, ''); // 1/10 of the training data
fann_save_train ($training_data_b, ''); // 9/10 of the training data
To Top