__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Phpml\NeuralNetwork;
use Phpml\Exception\InvalidArgumentException;
use Phpml\NeuralNetwork\Node\Neuron;
class Layer
{
/**
* @var Node[]
*/
private $nodes = [];
/**
* @throws InvalidArgumentException
*/
public function __construct(int $nodesNumber = 0, string $nodeClass = Neuron::class, ?ActivationFunction $activationFunction = null)
{
if (!in_array(Node::class, class_implements($nodeClass), true)) {
throw new InvalidArgumentException('Layer node class must implement Node interface');
}
for ($i = 0; $i < $nodesNumber; ++$i) {
$this->nodes[] = $this->createNode($nodeClass, $activationFunction);
}
}
public function addNode(Node $node): void
{
$this->nodes[] = $node;
}
/**
* @return Node[]
*/
public function getNodes(): array
{
return $this->nodes;
}
private function createNode(string $nodeClass, ?ActivationFunction $activationFunction = null): Node
{
if ($nodeClass === Neuron::class) {
return new Neuron($activationFunction);
}
return new $nodeClass();
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ActivationFunction | Folder | 0777 |
|
|
| Network | Folder | 0777 |
|
|
| Node | Folder | 0777 |
|
|
| Training | Folder | 0777 |
|
|
| ActivationFunction.php | File | 342 B | 0777 |
|
| Layer.php | File | 1.19 KB | 0777 |
|
| Network.php | File | 346 B | 0777 |
|
| Node.php | File | 124 B | 0777 |
|