PHP code example of devtronic / layerless
1. Go to this page and download the library: Download devtronic/layerless 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/ */
devtronic / layerless example snippets
// Import the SinusActivator as Activator
use Devtronic\Layerless\Activator\SinusActivator as Activator;
use Devtronic\Layerless\BiasNeuron;
use Devtronic\Layerless\InputNeuron;
use Devtronic\Layerless\Neuron;
use Devtronic\Layerless\Synapse;
// Load Composer autoload
Synapse(0.90, $inputA, $output);
new Synapse(0.23, $inputB, $output);
new Synapse(0.50, $bias, $output);
// Activate the neurons
$inputA->activate();
$inputB->activate();
$output->activate();
echo $output->getOutput() . PHP_EOL; // 0.98545
// Back propagate
$target = 0;
$output->calculateDelta($target);
$inputA->calculateDelta();
$inputB->calculateDelta();
$learningRate = 0.2;
$output->updateWeights($learningRate);
$inputA->updateWeights($learningRate);
$inputB->updateWeights($learningRate);
// Re-Check
$inputA->activate();
$inputB->activate();
$output->activate();
echo $output->getOutput() . PHP_EOL; // 0.92545