Rechercher une fonction PHP

XOR training

This example shows how to train data for XOR function

Example #1 xor.data file

4 2 1
-1 -1
-1
-1 1
1
1 -1
1
1 1
-1

Example #2 Simple train

<?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($annFANN_SIGMOID_SYMMETRIC);
    
fann_set_activation_function_output($annFANN_SIGMOID_SYMMETRIC);

    
$filename dirname(__FILE__) . "/xor.data";
    if (
fann_train_on_file($ann$filename$max_epochs$epochs_between_reports$desired_error))
        
fann_save($anndirname(__FILE__) . "/xor_float.net");

    
fann_destroy($ann);
}
?>

This example shows how to read and run data for XOR function

Example #3 Simple test

<?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(-11);
$calc_out fann_run($ann$input);
printf("xor test (%f,%f) -> %f\n"$input[0], $input[1], $calc_out[0]);
fann_destroy($ann);
?>

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-fann.examples-1.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut