MonoLayer Perceptron
All checks were successful
linter / quality (push) Successful in 6m16s
tests / ci (8.4) (push) Successful in 4m10s
tests / ci (8.5) (push) Successful in 4m29s

This commit is contained in:
2026-04-04 16:45:04 +02:00
parent f6620c2eca
commit 2f4db07918
21 changed files with 641 additions and 226 deletions

View File

@@ -2,9 +2,9 @@
namespace App\Models\Perceptrons;
use Illuminate\Database\Eloquent\Model;
// use Illuminate\Database\Eloquent\Model;
abstract class Perceptron extends Model
abstract class Perceptron
{
public function __construct(
private array $synaptic_weights,
@@ -12,7 +12,7 @@ abstract class Perceptron extends Model
$this->synaptic_weights = $synaptic_weights;
}
public function test(array $inputs): float
public function test(array $inputs): array
{
$inputs = array_merge([1], $inputs); // Add bias input
@@ -22,7 +22,7 @@ abstract class Perceptron extends Model
$weighted_sum = array_sum(array_map(fn ($input, $weight) => $input * $weight, $inputs, $this->synaptic_weights));
return $this->activationFunction($weighted_sum);
return [$this->activationFunction($weighted_sum)];
}
abstract public function activationFunction(float $weighted_sum): float;