Passed
Push — master ( cacfd6...0e59cf )
by Arkadiusz
03:10 queued 42s
created

ThresholdedReLU::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phpml\NeuralNetwork\ActivationFunction;
6
7
use Phpml\NeuralNetwork\ActivationFunction;
8
9
class ThresholdedReLU implements ActivationFunction
10
{
11
    /**
12
     * @var float
13
     */
14
    private $theta;
15
16
    /**
17
     * @param float $theta
18
     */
19
    public function __construct($theta = 1.0)
20
    {
21
        $this->theta = $theta;
22
    }
23
24
    /**
25
     * @param float|int $value
26
     *
27
     * @return float
28
     */
29
    public function compute($value): float
30
    {
31
        return $value > $this->theta ? $value : 0.0;
32
    }
33
}
34