Added Limited Epoch Event Buffer

for better frontend performance when using big  max epoch number
This commit is contained in:
2026-03-21 09:42:05 +01:00
parent f0e7be4476
commit 6abb417430
10 changed files with 149 additions and 22 deletions

View File

@@ -2,15 +2,11 @@
namespace App\Services;
use Illuminate\Support\Facades\Log;
class PerceptronIterationEventBuffer {
class PerceptronIterationEventBuffer implements IPerceptronIterationEventBuffer {
private $data;
private int $nextSizeIncreaseThreshold;
private int $underSizeIncreaseCount = 0;
private int $MAX_SIZE = 50;
public function __construct(
private string $sessionId,
private string $trainingId,
@@ -26,9 +22,9 @@ class PerceptronIterationEventBuffer {
$this->data = [];
}
public function addIteration(int $iteration, int $exampleIndex, float $error, array $synaptic_weights): void {
public function addIteration(int $epoch, int $exampleIndex, float $error, array $synaptic_weights): void {
$this->data[] = [
"iteration" => $iteration,
"epoch" => $epoch,
"exampleIndex" => $exampleIndex,
"error" => $error,
"weights" => $synaptic_weights,
@@ -42,8 +38,8 @@ class PerceptronIterationEventBuffer {
$this->flush();
$this->nextSizeIncreaseThreshold *= $this->sizeIncreaseFactor;
if ($this->nextSizeIncreaseThreshold > $this->MAX_SIZE) {
$this->nextSizeIncreaseThreshold = $this->MAX_SIZE; // Cap the threshold to the maximum size
if ($this->nextSizeIncreaseThreshold > config('perceptron.broadcast_iteration_size')) {
$this->nextSizeIncreaseThreshold = config('perceptron.broadcast_iteration_size'); // Cap the threshold to the maximum size
}
}
}