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