neuralnet.php/public/main.php

30 lines
830 B
PHP

<?php define('__ROOT__', dirname(dirname(__FILE__)) );
require_once __ROOT__.'/autoloader.php';
use \neuralnetwork\core\NeuralNetwork;
use \filemanager\core\FileManager;
function behaviour($abc){
return [($abc[0] & $abc[1]) ^ $abc[2]];
}
echo "Welcome to neural-network.php\n";
echo "-----------------------------\n";
$nn = NeuralNetwork::create(50, 100);
$nn->setMaxValues([1, 1, 1], [1]);
$d = [0, 0, 0]; $nn->addSample($d, behaviour($d));
$d = [0, 0, 1]; $nn->addSample($d, behaviour($d));
$d = [0, 1, 0]; $nn->addSample($d, behaviour($d));
$d = [0, 1, 1]; $nn->addSample($d, behaviour($d));
$d = [1, 0, 0]; $nn->addSample($d, behaviour($d));
$d = [1, 0, 1]; $nn->addSample($d, behaviour($d));
$d = [1, 1, 0]; $nn->addSample($d, behaviour($d));
$d = [1, 1, 1]; $nn->addSample($d, behaviour($d));
?>