| 1 | <?php |
||
| 10 | abstract class Optimizer |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Unknown variables to be found |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $theta = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Number of dimensions |
||
| 21 | * |
||
| 22 | * @var int |
||
| 23 | */ |
||
| 24 | protected $dimensions; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Inits a new instance of Optimizer for the given number of dimensions |
||
| 28 | */ |
||
| 29 | public function __construct(int $dimensions) |
||
| 39 | |||
| 40 | public function setTheta(array $theta): self |
||
| 50 | |||
| 51 | public function theta(): array |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Executes the optimization with the given samples & targets |
||
| 58 | * and returns the weights |
||
| 59 | */ |
||
| 60 | abstract public function runOptimization(array $samples, array $targets, Closure $gradientCb): array; |
||
| 61 | } |
||
| 62 |