2017-12-05 20:09:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-01-06 20:25:47 +00:00
|
|
|
namespace Phpml\Tests\NeuralNetwork\Network;
|
2017-12-05 20:09:06 +00:00
|
|
|
|
|
|
|
use Phpml\NeuralNetwork\Network\MultilayerPerceptron;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class MultilayerPerceptronTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testLearningRateSetter(): void
|
|
|
|
{
|
2018-01-06 20:25:47 +00:00
|
|
|
/** @var MultilayerPerceptron $mlp */
|
2017-12-05 20:09:06 +00:00
|
|
|
$mlp = $this->getMockForAbstractClass(
|
|
|
|
MultilayerPerceptron::class,
|
|
|
|
[5, [3], [0, 1], 1000, null, 0.42]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(0.42, $this->readAttribute($mlp, 'learningRate'));
|
|
|
|
$backprop = $this->readAttribute($mlp, 'backpropagation');
|
|
|
|
$this->assertEquals(0.42, $this->readAttribute($backprop, 'learningRate'));
|
|
|
|
|
|
|
|
$mlp->setLearningRate(0.24);
|
|
|
|
$this->assertEquals(0.24, $this->readAttribute($mlp, 'learningRate'));
|
|
|
|
$backprop = $this->readAttribute($mlp, 'backpropagation');
|
|
|
|
$this->assertEquals(0.24, $this->readAttribute($backprop, 'learningRate'));
|
|
|
|
}
|
|
|
|
}
|