File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,26 @@ public function layers() : Traversable
131
131
yield $ this ->output ;
132
132
}
133
133
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
+
134
154
/**
135
155
* Initialize the parameters of the layers and warm the optimizer cache.
136
156
*/
Original file line number Diff line number Diff line change 18
18
*
19
19
* @var float
20
20
*/
21
- const EPSILON = 1e-16 ;
21
+ const EPSILON = 1e-8 ;
22
22
23
23
/**
24
24
* The natural logarithm of the epsilon constant.
You can’t perform that action at this time.
0 commit comments