2017-09-02 19:30:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace tests\Phpml\NeuralNetwork\ActivationFunction;
|
|
|
|
|
|
|
|
use Phpml\NeuralNetwork\ActivationFunction\ThresholdedReLU;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class ThresholdedReLUTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider thresholdProvider
|
|
|
|
*/
|
2017-11-14 20:21:23 +00:00
|
|
|
public function testThresholdedReLUActivationFunction($theta, $expected, $value): void
|
2017-09-02 19:30:35 +00:00
|
|
|
{
|
|
|
|
$thresholdedReLU = new ThresholdedReLU($theta);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $thresholdedReLU->compute($value));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function thresholdProvider()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[1.0, 0, 1.0],
|
|
|
|
[0.5, 3.75, 3.75],
|
|
|
|
[0.0, 0.5, 0.5],
|
|
|
|
[0.9, 0, 0.1]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|