1 | <?php |
||
11 | class GD extends StochasticGD |
||
12 | { |
||
13 | /** |
||
14 | * Number of samples given |
||
15 | * |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $sampleCount = null; |
||
19 | |||
20 | /** |
||
21 | * @param array $samples |
||
22 | * @param array $targets |
||
23 | * @param \Closure $gradientCb |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | public function runOptimization(array $samples, array $targets, \Closure $gradientCb) |
||
56 | |||
57 | /** |
||
58 | * Calculates gradient, cost function and penalty term for each sample |
||
59 | * then returns them as an array of values |
||
60 | * |
||
61 | * @param array $theta |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | protected function gradient(array $theta) |
||
86 | |||
87 | /** |
||
88 | * @param array $updates |
||
89 | * @param float $penalty |
||
90 | */ |
||
91 | protected function updateWeightsWithUpdates(array $updates, float $penalty) |
||
110 | |||
111 | /** |
||
112 | * Clears the optimizer internal vars after the optimization process. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | protected function clear() |
||
121 | } |
||
122 |