1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 07:02:06 +01:00
Files
archived-doc-fr/reference/fann/examples.xml
Louis-Arnaud 4a8a9ab18c Review/ref minor fixes (#2525)
* Fix fann: Cette→Cet exemple, translate setup.xml titles
* Fix filter-input: add missing return value for unset variable
* Fix ftp-login: translate die() string to French
* Fix gearman examples: translate English comments to French
* Fix gmp: parameter names num1→num2, mod→modulus, double period
* Fix imap-open: translate Mailboxes heading to French
* Fix network/header: translate English code comments to French
* Fix openssl-encrypt: translate English code strings and comments
* Fix sockets/examples: translate English comment to French
* Fix lua/setup: grammar error avoir d'installer → avoir installé
2026-02-25 08:14:00 +01:00

82 lines
2.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: c2aeb63e3d8b50f83d5adeffea4209db45705c76 Maintainer: Fan2Shrek Status: ready -->
<!-- Reviewed: yes -->
<chapter xml:id="fann.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="fann.examples-1">
<title>XOR training</title>
<para>
Cet exemple montre comment entraîner des données pour la fonction XOR
<example>
<title>Fichier xor.data</title>
<programlisting role="txt">
<![CDATA[
4 2 1
-1 -1
-1
-1 1
1
1 -1
1
1 1
-1
]]>
</programlisting>
</example>
<example>
<title>Entraînement simple</title>
<programlisting role="php">
<![CDATA[
<?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);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
Cet exemple montre comment lire et exécuter des données pour la fonction XOR
<example>
<title>Test simple</title>
<programlisting role="php">
<![CDATA[
<?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);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>