Refactored into folders
This commit is contained in:
25
tests/Unit/Training/TrainingTestCase.php
Normal file
25
tests/Unit/Training/TrainingTestCase.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Training;
|
||||
|
||||
use App\Models\NetworkTraining;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TrainingTestCase extends TestCase
|
||||
{
|
||||
public const MARGIN_OF_ERROR = 0.001;
|
||||
|
||||
public function verifyTrainingResults(NetworkTraining $training, array $expectedWeights, int $expectedEpochs): void
|
||||
{
|
||||
$training->start();
|
||||
|
||||
|
||||
// Assert that the final synaptic weights are as expected withing the margin of error
|
||||
$finalWeights = $training->getSynapticWeights();
|
||||
$this->assertEqualsWithDelta($expectedWeights, $finalWeights, self::MARGIN_OF_ERROR, "Final synaptic weights do not match expected values.");
|
||||
|
||||
// Assert that the number of epochs taken is as expected
|
||||
$this->assertEquals($expectedEpochs, $training->getEpoch(), "Expected training to take $expectedEpochs epochs, but it took {$training->getEpoch()} epochs.");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user