Fix linting
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Services\IterationEventBuffer;
|
||||
|
||||
interface IPerceptronIterationEventBuffer {
|
||||
interface IPerceptronIterationEventBuffer
|
||||
{
|
||||
public function flush(): void;
|
||||
|
||||
public function flush(): void ;
|
||||
|
||||
public function addIteration(int $iteration, int $exampleIndex, float $error, array $synaptic_weights): void ;
|
||||
public function addIteration(int $iteration, int $exampleIndex, float $error, array $synaptic_weights): void;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace App\Services\IterationEventBuffer;
|
||||
|
||||
class PerceptronIterationEventBuffer implements IPerceptronIterationEventBuffer {
|
||||
class PerceptronIterationEventBuffer implements IPerceptronIterationEventBuffer
|
||||
{
|
||||
private $data;
|
||||
|
||||
private int $nextSizeIncreaseThreshold;
|
||||
|
||||
private int $underSizeIncreaseCount = 0;
|
||||
|
||||
public function __construct(
|
||||
@@ -17,24 +20,25 @@ class PerceptronIterationEventBuffer implements IPerceptronIterationEventBuffer
|
||||
$this->nextSizeIncreaseThreshold = $sizeIncreaseStart;
|
||||
}
|
||||
|
||||
public function flush(): void {
|
||||
public function flush(): void
|
||||
{
|
||||
event(new \App\Events\PerceptronTrainingIteration($this->data, $this->sessionId, $this->trainingId));
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
public function addIteration(int $epoch, int $exampleIndex, float $error, array $synaptic_weights): void {
|
||||
public function addIteration(int $epoch, int $exampleIndex, float $error, array $synaptic_weights): void
|
||||
{
|
||||
$this->data[] = [
|
||||
"epoch" => $epoch,
|
||||
"exampleIndex" => $exampleIndex,
|
||||
"error" => $error,
|
||||
"weights" => $synaptic_weights,
|
||||
'epoch' => $epoch,
|
||||
'exampleIndex' => $exampleIndex,
|
||||
'error' => $error,
|
||||
'weights' => $synaptic_weights,
|
||||
];
|
||||
|
||||
if ($this->underSizeIncreaseCount <= $this->sizeIncreaseStart) { // We can still send a single date because we are under the increase start threshold
|
||||
$this->underSizeIncreaseCount++;
|
||||
$this->flush();
|
||||
}
|
||||
else if (count($this->data) >= $this->nextSizeIncreaseThreshold) {
|
||||
} elseif (count($this->data) >= $this->nextSizeIncreaseThreshold) {
|
||||
$this->flush();
|
||||
$this->nextSizeIncreaseThreshold *= $this->sizeIncreaseFactor;
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Services\IterationEventBuffer;
|
||||
|
||||
class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuffer {
|
||||
class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuffer
|
||||
{
|
||||
private array $data;
|
||||
|
||||
private int $underSizeIncreaseCount = 0;
|
||||
|
||||
public function __construct(
|
||||
@@ -15,23 +17,26 @@ class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuff
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
public function flush(): void {
|
||||
public function flush(): void
|
||||
{
|
||||
event(new \App\Events\PerceptronTrainingIteration($this->data, $this->sessionId, $this->trainingId));
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
public function addIteration(int $epoch, int $exampleIndex, float $error, array $synaptic_weights): void {
|
||||
public function addIteration(int $epoch, int $exampleIndex, float $error, array $synaptic_weights): void
|
||||
{
|
||||
$newData = [
|
||||
"epoch" => $epoch,
|
||||
"exampleIndex" => $exampleIndex,
|
||||
"error" => $error,
|
||||
"weights" => $synaptic_weights,
|
||||
'epoch' => $epoch,
|
||||
'exampleIndex' => $exampleIndex,
|
||||
'error' => $error,
|
||||
'weights' => $synaptic_weights,
|
||||
];
|
||||
|
||||
if ($this->underSizeIncreaseCount <= $this->sizeIncreaseStart) { // Special case where we need to send each iteration separately
|
||||
$this->underSizeIncreaseCount++;
|
||||
$this->data[] = $newData;
|
||||
$this->flush();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,8 +44,7 @@ class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuff
|
||||
if ($this->data && $lastEpoch !== $epoch) { // Current Epoch has changed from the last one
|
||||
if ($lastEpoch % $this->epochInterval === 0) { // The last epoch need to be sent
|
||||
$this->flush(); // Flush all data from the previous epoch
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user