__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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\Node;
use Phpml\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\Sigmoid;
use Phpml\NeuralNetwork\Node;
use Phpml\NeuralNetwork\Node\Neuron\Synapse;
class Neuron implements Node
{
/**
* @var Synapse[]
*/
protected $synapses = [];
/**
* @var ActivationFunction
*/
protected $activationFunction;
/**
* @var float
*/
protected $output = 0.0;
/**
* @var float
*/
protected $z = 0.0;
public function __construct(?ActivationFunction $activationFunction = null)
{
$this->activationFunction = $activationFunction ?? new Sigmoid();
}
public function addSynapse(Synapse $synapse): void
{
$this->synapses[] = $synapse;
}
/**
* @return Synapse[]
*/
public function getSynapses(): array
{
return $this->synapses;
}
public function getOutput(): float
{
if ($this->output === 0.0) {
$this->z = 0;
foreach ($this->synapses as $synapse) {
$this->z += $synapse->getOutput();
}
$this->output = $this->activationFunction->compute($this->z);
}
return $this->output;
}
public function getDerivative(): float
{
return $this->activationFunction->differentiate($this->z, $this->output);
}
public function reset(): void
{
$this->output = 0.0;
$this->z = 0.0;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Neuron | Folder | 0777 |
|
|
| Bias.php | File | 203 B | 0777 |
|
| Input.php | File | 457 B | 0777 |
|
| Neuron.php | File | 1.5 KB | 0777 |
|