Various fixess and xor
linter / quality (push) Successful in 4m23s
tests / ci (8.4) (push) Successful in 4m35s
tests / ci (8.5) (push) Successful in 5m13s

This commit is contained in:
2026-09-08 18:40:56 +02:00
parent 08aa04fe56
commit 8a50f492ac
7 changed files with 93 additions and 5 deletions
+8 -1
View File
@@ -6,6 +6,7 @@ use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Support\Arr;
use Illuminate\Queue\SerializesModels;
class PerceptronTrainingIteration implements ShouldBroadcast
@@ -38,9 +39,15 @@ class PerceptronTrainingIteration implements ShouldBroadcast
public function broadcastWith(): array
{
$weights = collect($this->iterations)
->pluck('weights')
->first(fn (array $weights): bool => $weights !== []);
$shouldBroadcastAllWeights = $weights !== null
&& count(Arr::flatten($weights)) <= config('perceptron.max_displayed_weights');
$lastIterationIndex = count($this->iterations) - 1;
$iterations = array_map(
fn (array $iteration, int $index): array => $index === $lastIterationIndex
fn (array $iteration, int $index): array => $shouldBroadcastAllWeights || $index === $lastIterationIndex
? $iteration
: [...$iteration, 'weights' => []],
$this->iterations,
@@ -47,6 +47,7 @@ class PerceptronController extends Controller
break;
case 'multilayer':
$learningRate = 0.8;
$maxIterations = 2000;
break;
}
@@ -109,6 +110,17 @@ class PerceptronController extends Controller
break;
}
break;
case 'logic_xor':
switch ($perceptronType) {
case 'multilayer':
$dataset['defaultLearningRate'] = 0.3;
$dataset['defaultMinError'] = 0.001;
$dataset['defaultMaxIterations'] = 500;
$dataset['defaultHiddenLayers'] = 1;
$dataset['defaultHiddenLayersNeurons'] = 2;
break;
}
break;
case 'table_2_9':
switch ($perceptronType) {
case 'simple':
@@ -132,6 +144,15 @@ class PerceptronController extends Controller
break;
}
break;
case 'table_4_17':
switch ($perceptronType) {
case 'multilayer':
$dataset['defaultLearningRate'] = 0.5;
$dataset['defaultMinError'] = 0.08;
$dataset['defaultMaxIterations'] = 400;
break;
}
break;
}
$datasets[] = $dataset;
}