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

@@ -0,0 +1,35 @@
<?php
namespace App\Services\SynapticWeightsProvider;
use App\Services\SynapticWeightsProvider\INetworkSynapticWeightsProvider;
class SimpleNetworkWeightsProvider implements INetworkSynapticWeightsProvider
{
public function __construct(
private ISynapticWeightsProvider $synapticWeightsProvider,
) {
}
public function generate(int $input_size, int $output_size, int $hidden_layers_count, int $hidden_layers_neurons_count): array
{
$synaptic_weights = [];
$lastLayerSize = $input_size;
// Generate Hidden Layer weights
for ($hiddenLayerNeuronIndex = 0; $hiddenLayerNeuronIndex < $hidden_layers_count; $hiddenLayerNeuronIndex++) {
for ($neuronIndex = 0; $neuronIndex < $hidden_layers_neurons_count; $neuronIndex++) {
$synaptic_weights[] = $this->synapticWeightsProvider->generate($lastLayerSize);
}
$lastLayerSize = $hidden_layers_neurons_count;
}
// Generate Output Layer weights
$synaptic_weights[] = [];
for ($outputNeuronIndex = 0; $outputNeuronIndex < $output_size; $outputNeuronIndex++) {
$synaptic_weights[count($synaptic_weights) -1][] = $this->synapticWeightsProvider->generate($lastLayerSize);
}
return $synaptic_weights;
}
}