PHP code example of lambdacasserole / brainy

1. Go to this page and download the library: Download lambdacasserole/brainy 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/ */

    

lambdacasserole / brainy example snippets


// Create a new neural network with 3 input neurons, one layer of 4 hidden neurons, and 1 output neuron.
$network = new NeuralNetwork(3, 4, 1);

// Add training data to the network. In this case, we want the network to learn the 'XOR' function.
$network->addTrainingData([-1, -1, 1], [-1]);
$network->addTrainingData([-1, 1, 1], [1]);
$network->addTrainingData([1, -1, 1], [1]);
$network->addTrainingData([1, 1, 1], [-1]);

// Train in a maximum of 1000 epochs to a maximum error rate of 0.01.
$success = $network->train(1000, 0.01);

php composer.phar