Added configuration panel datasets, back-end refactor and others
This commit is contained in:
40
app/Models/NetworkTraining.php
Normal file
40
app/Models/NetworkTraining.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\PerceptronTrainingEnded;
|
||||
use App\Services\DataSetReader;
|
||||
use App\Services\PerceptronIterationEventBuffer;
|
||||
|
||||
abstract class NetworkTraining
|
||||
{
|
||||
protected int $iteration = 0;
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @var ActivationsFunctions
|
||||
*/
|
||||
public ActivationsFunctions $activationFunction;
|
||||
|
||||
public function __construct(
|
||||
protected DataSetReader $datasetReader,
|
||||
protected int $maxIterations,
|
||||
protected PerceptronIterationEventBuffer $iterationEventBuffer,
|
||||
protected string $sessionId,
|
||||
protected string $trainingId,
|
||||
) {
|
||||
}
|
||||
|
||||
abstract public function start() : void;
|
||||
abstract protected function stopCondition(): bool;
|
||||
|
||||
protected function checkPassedMaxIterations() {
|
||||
if ($this->iteration >= $this->maxIterations) {
|
||||
event(new PerceptronTrainingEnded('Le nombre maximal d\'itérations a été atteint', $this->sessionId, $this->trainingId));
|
||||
}
|
||||
}
|
||||
|
||||
protected function addIterationToBuffer(float $error, array $synapticWeights) {
|
||||
$this->iterationEventBuffer->addIteration($this->iteration, $this->datasetReader->getLastReadLineIndex(), $error, $synapticWeights);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user