MonoLayer Perceptron
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user