Passed
Push — master ( 0e59cf...b1be05 )
by Arkadiusz
05:05 queued 02:32
created

PReLU::__construct()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 4
Code Lines 2

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 PReLU implements ActivationFunction
10
{
11
    /**
12
     * @var float
13
     */
14
    private $beta;
15
16
    /**
17
     * @param float $beta
18
     */
19
    public function __construct($beta = 0.01)
20
    {
21
        $this->beta = $beta;
22
    }
23
24
    /**
25
     * @param float|int $value
26
     *
27
     * @return float
28
     */
29
    public function compute($value): float
30
    {
31
        return $value >= 0 ? $value : $this->beta * $value;
32
    }
33
}
34