Here is an explanation for the input file for training, as it might be obvious to everyone and you must understand it to write your own:
4 2 1 <- header file saying there are 4 sets to read, with 2 inputs and 1 output
-1 -1 <- the 2 inputs for the 1st group
-1 <- the 1 output for the 1st group
-1 1 <- the 2 inputs for the 2nd group
1 <- the 1 output for the 2nd group
1 -1 <- the 2 inputs for the 3rd group
1 <- the 1 output for the 3rd group
1 1 <- the 2 inputs for the 4th group
-1 <- the 1 output for the 4th group
PHP.mk документација
XOR обука
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
fann.examples-1.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + преведен приказ
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
fann.examples-1.php
XOR обука
Референца за `fann.examples-1.php` со подобрена типографија и навигација.
XOR обука
Овој пример покажува како да се обучат податоци за XOR функција
Пример #1 xor.data датотека
4 2 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1
Пример #2 Едноставна обука
<?php
$num_input = 2;
$num_output = 1;
$num_layers = 3;
$num_neurons_hidden = 3;
$desired_error = 0.001;
$max_epochs = 500000;
$epochs_between_reports = 1000;
$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);
if ($ann) {
fann_set_activation_function_hidden($ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output($ann, FANN_SIGMOID_SYMMETRIC);
$filename = dirname(__FILE__) . "/xor.data";
if (fann_train_on_file($ann, $filename, $max_epochs, $epochs_between_reports, $desired_error))
fann_save($ann, dirname(__FILE__) . "/xor_float.net");
fann_destroy($ann);
}
?>Овој пример покажува како да се прочитаат и извршат податоци за XOR функција
Пример #3 Едноставен тест
<?php
$train_file = (dirname(__FILE__) . "/xor_float.net");
if (!is_file($train_file))
die("The file xor_float.net has not been created! Please run simple_train.php to generate it");
$ann = fann_create_from_file($train_file);
if (!$ann)
die("ANN could not be created");
$input = array(-1, 1);
$calc_out = fann_run($ann, $input);
printf("xor test (%f,%f) -> %f\n", $input[0], $input[1], $calc_out[0]);
fann_destroy($ann);
?>Белешки од корисници 3 белешки
RPaseur at NationalPres dot org ¶
пред 10 години
Ray.Paseur понекогаш користи Gmail ¶
пред 9 години
A helpful reference for FANN is available here:
http://leenissen.dk/fann/html/files2/theory-txt.html
ithirzty ¶
пред 6 години
If you wan't your result to be saved after the time limit, you will need to add this to your code.
<?php
function shutdown()
{
global $ann;
fann_save($ann, dirname(__FILE__) . "/result.net");
fann_destroy($ann);
}
register_shutdown_function('shutdown');
?>
where $ann is your neural network var and 'result.net' your neural network config file.