Multilayer neuron network
This commit is contained in:
@@ -25,7 +25,7 @@ class NetworkPerceptron extends Perceptron
|
||||
}
|
||||
|
||||
// Hidden Layer
|
||||
for ($layerIndex = 0; $layerIndex < count($synaptic_weights) - 2; $layerIndex++) {
|
||||
for ($layerIndex = 0; $layerIndex < count($synaptic_weights) - 1; $layerIndex++) {
|
||||
$this->network[$layerIndex + 1] = [];
|
||||
|
||||
foreach ($synaptic_weights[$layerIndex] as $neuronWeights) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Perceptrons;
|
||||
|
||||
class SigmoidPerceptron extends Perceptron
|
||||
{
|
||||
public function activationFunction(float $weighted_sum): float
|
||||
{
|
||||
$weighted_sum = max(-40, min(40, $weighted_sum));
|
||||
|
||||
return 1 / (1 + exp(-$weighted_sum));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user