Skip to content

Commit 04d77b4

Browse files
committed
Fix branch
1 parent e0957f1 commit 04d77b4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/NeuralNet/Network.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ public function layers() : Traversable
131131
yield $this->output;
132132
}
133133

134+
/**
135+
* Return the number of trainable parameters in the network.
136+
*
137+
* @return int
138+
*/
139+
public function numParams() : int
140+
{
141+
$numParams = 0;
142+
143+
foreach ($this->layers() as $layer) {
144+
if ($layer instanceof Parametric) {
145+
foreach ($layer->parameters() as $parameter) {
146+
$numParams += $parameter->param()->size();
147+
}
148+
}
149+
}
150+
151+
return $numParams;
152+
}
153+
134154
/**
135155
* Initialize the parameters of the layers and warm the optimizer cache.
136156
*/

src/constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @var float
2020
*/
21-
const EPSILON = 1e-16;
21+
const EPSILON = 1e-8;
2222

2323
/**
2424
* The natural logarithm of the epsilon constant.

0 commit comments

Comments
 (0)