mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-05 13:07:52 +00:00
create Network and Training contracts
This commit is contained in:
parent
95b29d40b1
commit
12ee62bbca
20
src/Phpml/NeuralNetwork/Network.php
Normal file
20
src/Phpml/NeuralNetwork/Network.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace Phpml\NeuralNetwork;
|
||||||
|
|
||||||
|
interface Network extends Node
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $input
|
||||||
|
*/
|
||||||
|
public function setInput($input);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLayers(): array;
|
||||||
|
|
||||||
|
}
|
36
src/Phpml/NeuralNetwork/Network/LayeredNetwork.php
Normal file
36
src/Phpml/NeuralNetwork/Network/LayeredNetwork.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace Phpml\NeuralNetwork\Network;
|
||||||
|
|
||||||
|
use Phpml\NeuralNetwork\Network;
|
||||||
|
|
||||||
|
abstract class LayeredNetwork implements Network
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLayers(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getOutput(): float
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $input
|
||||||
|
*/
|
||||||
|
public function setInput($input)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/Phpml/NeuralNetwork/Network/MultilayerPerceptron.php
Normal file
10
src/Phpml/NeuralNetwork/Network/MultilayerPerceptron.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace Phpml\NeuralNetwork\Network;
|
||||||
|
|
||||||
|
class MultilayerPerceptron extends LayeredNetwork
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
16
src/Phpml/NeuralNetwork/Training.php
Normal file
16
src/Phpml/NeuralNetwork/Training.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace Phpml\NeuralNetwork;
|
||||||
|
|
||||||
|
interface Training
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $samples
|
||||||
|
* @param array $targets
|
||||||
|
* @param float $desiredError
|
||||||
|
* @param int $maxIterations
|
||||||
|
*/
|
||||||
|
public function train(array $samples, array $targets, float $desiredError = 0.001, int $maxIterations = 10000);
|
||||||
|
}
|
23
src/Phpml/NeuralNetwork/Training/Backpropagation.php
Normal file
23
src/Phpml/NeuralNetwork/Training/Backpropagation.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace Phpml\NeuralNetwork\Training;
|
||||||
|
|
||||||
|
use Phpml\NeuralNetwork\Training;
|
||||||
|
|
||||||
|
class Backpropagation implements Training
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $samples
|
||||||
|
* @param array $targets
|
||||||
|
* @param float $desiredError
|
||||||
|
* @param int $maxIterations
|
||||||
|
*/
|
||||||
|
public function train(array $samples, array $targets, float $desiredError = 0.001, int $maxIterations = 10000)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user