/** * Update the Hopfield weights after training. * * @param * Matrix delta * The amount to change the weights by. */ private function convertHopfieldMatrix(Matrix $delta) { // add the new weight matrix to what is there already for ($row = 0; $row < $delta->getRows(); ++$row) { for ($col = 0; $col < $delta->getRows(); ++$col) { $this->addWeight($row, $col, $delta->get($row, $col)); } } }
public function testPackedArray2() { $data = [1.0, 2.0, 3.0, 4.0]; $matrix = new Matrix(1, 4); $matrix->fromPackedArray($data, 0); $this->assertEquals(1.0, $matrix->get(0, 0)); $this->assertEquals(2.0, $matrix->get(0, 1)); $this->assertEquals(3.0, $matrix->get(0, 2)); }