PHP code example of patrickschur / neural-network

1. Go to this page and download the library: Download patrickschur/neural-network library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

patrickschur / neural-network example snippets


// Creates the neural network
$nn = new NeuralNetwork();
 
// Creates four input neurons
$i1 = $nn->createNewInput();
$i2 = $nn->createNewInput();
$i3 = $nn->createNewInput();
$i4 = $nn->createNewInput();
 
// Sets the input for each input neuron
$i1->setValue(1);
$i2->setValue(2);
$i3->setValue(3);
$i4->setValue(4);
 
// Creates the output neuron
$o1 = $nn->createNewOutput(new Identity());
 
// Sets the weights and connect each input to the output neuron
$nn->createFullMesh(0, 0, 0, 0);
 
echo $o1->getValue(); // Output 0