Skip to content

Commit d05d9bf

Browse files
committed
code style fixes
1 parent 7b220c6 commit d05d9bf

File tree

3 files changed

+18
-46
lines changed

3 files changed

+18
-46
lines changed

src/NeuralNet/ActivationFunctions/Sigmoid/Sigmoid.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public function activate(NDArray $input) : NDArray
3535
{
3636
// Calculate e^(-x)
3737
$negExp = NumPower::exp(NumPower::multiply(-1.0, $input));
38-
38+
3939
// Calculate 1 + e^(-x)
4040
$denominator = NumPower::add(1.0, $negExp);
41-
41+
4242
// Calculate 1 / (1 + e^(-x))
4343
return NumPower::divide(1.0, $denominator);
4444
}
@@ -57,7 +57,7 @@ public function differentiate(NDArray $output) : NDArray
5757
{
5858
// Calculate (1 - output)
5959
$oneMinusOutput = NumPower::subtract(1.0, $output);
60-
60+
6161
// Calculate output * (1 - output)
6262
return NumPower::multiply($output, $oneMinusOutput);
6363
}

tests/NeuralNet/ActivationFunctions/SELU/SELUTest.php

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
#[CoversClass(SELU::class)]
2020
class SELUTest extends TestCase
2121
{
22-
/**
23-
* @var SELU
24-
*/
25-
protected SELU $activationFn;
26-
2722
/**
2823
* The value at which leakage starts to saturate.
2924
*
@@ -45,6 +40,11 @@ class SELUTest extends TestCase
4540
*/
4641
protected const BETA = self::LAMBDA * self::ALPHA;
4742

43+
/**
44+
* @var SELU
45+
*/
46+
protected SELU $activationFn;
47+
4848
/**
4949
* @return Generator<array>
5050
*/
@@ -69,17 +69,17 @@ public static function computeProvider() : Generator
6969
[
7070
self::BETA * (exp(-0.12) - 1.0),
7171
0.31 * self::LAMBDA,
72-
self::BETA * (exp(-0.49) - 1.0)
72+
self::BETA * (exp(-0.49) - 1.0),
7373
],
7474
[
7575
0.99 * self::LAMBDA,
7676
0.08 * self::LAMBDA,
77-
self::BETA * (exp(-0.03) - 1.0)
77+
self::BETA * (exp(-0.03) - 1.0),
7878
],
7979
[
8080
0.05 * self::LAMBDA,
8181
self::BETA * (exp(-0.52) - 1.0),
82-
0.54 * self::LAMBDA
82+
0.54 * self::LAMBDA,
8383
],
8484
],
8585
];
@@ -95,15 +95,7 @@ public static function differentiateProvider() : Generator
9595
[2.0, 1.0, -0.5, 0.0, 20.0, -10.0, -20],
9696
]),
9797
[
98-
[
99-
self::LAMBDA,
100-
self::LAMBDA,
101-
1.0663410,
102-
1.7580991,
103-
self::LAMBDA,
104-
0.0000798,
105-
0.0
106-
],
98+
[self::LAMBDA, self::LAMBDA, 1.0663410, 1.7580991, self::LAMBDA, 0.0000798, 0.0],
10799
],
108100
];
109101

@@ -114,21 +106,9 @@ public static function differentiateProvider() : Generator
114106
[0.05, -0.52, 0.54],
115107
]),
116108
[
117-
[
118-
self::BETA * exp(-0.12),
119-
self::LAMBDA,
120-
self::BETA * exp(-0.49)
121-
],
122-
[
123-
self::LAMBDA,
124-
self::LAMBDA,
125-
self::BETA * exp(-0.03)
126-
],
127-
[
128-
self::LAMBDA,
129-
self::BETA * exp(-0.52),
130-
self::LAMBDA
131-
],
109+
[self::BETA * exp(-0.12), self::LAMBDA, self::BETA * exp(-0.49)],
110+
[self::LAMBDA, self::LAMBDA, self::BETA * exp(-0.03)],
111+
[self::LAMBDA, self::BETA * exp(-0.52), self::LAMBDA],
132112
],
133113
];
134114
}
@@ -156,18 +136,10 @@ public static function zeroRegionProvider() : Generator
156136
yield [
157137
NumPower::array([[-1e-15, -1e-10, -1e-7]]),
158138
[
159-
[
160-
self::BETA * (exp(-1e-15) - 1.0),
161-
self::BETA * (exp(-1e-10) - 1.0),
162-
self::BETA * (exp(-1e-7) - 1.0),
163-
],
139+
[self::BETA * (exp(-1e-15) - 1.0), self::BETA * (exp(-1e-10) - 1.0), self::BETA * (exp(-1e-7) - 1.0)],
164140
],
165141
[
166-
[
167-
self::BETA * exp(-1e-15),
168-
self::BETA * exp(-1e-10),
169-
self::BETA * exp(-1e-7),
170-
],
142+
[self::BETA * exp(-1e-15), self::BETA * exp(-1e-10), self::BETA * exp(-1e-7)],
171143
],
172144
];
173145

tests/NeuralNet/ActivationFunctions/Sigmoid/SigmoidTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static function zeroRegionProvider() : Generator
109109
// Test values around machine epsilon
110110
yield [
111111
NumPower::array([[PHP_FLOAT_EPSILON, -PHP_FLOAT_EPSILON]]),
112-
[[0.5 + PHP_FLOAT_EPSILON/2, 0.5 - PHP_FLOAT_EPSILON/2]],
112+
[[0.5 + PHP_FLOAT_EPSILON / 2, 0.5 - PHP_FLOAT_EPSILON / 2]],
113113
[[0.25, 0.25]],
114114
];
115115
}

0 commit comments

Comments
 (0)