| 1 | <?php declare(strict_types=1); |
||
| 5 | abstract class Optimizer |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Unknown variables to be found |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $theta; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Number of dimensions |
||
| 16 | * |
||
| 17 | * @var int |
||
| 18 | */ |
||
| 19 | protected $dimensions; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Inits a new instance of Optimizer for the given number of dimensions |
||
| 23 | * |
||
| 24 | * @param int $dimensions |
||
| 25 | */ |
||
| 26 | public function __construct(int $dimensions) |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Sets the weights manually |
||
| 39 | * |
||
| 40 | * @param array $theta |
||
| 41 | */ |
||
| 42 | public function setInitialTheta(array $theta) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Executes the optimization with the given samples & targets |
||
| 55 | * and returns the weights |
||
| 56 | * |
||
| 57 | */ |
||
| 58 | abstract protected function runOptimization(array $samples, array $targets, \Closure $gradientCb); |
||
| 59 | } |
||
| 60 |