def test_1(self): (f, g, i) = steepest(self.rows, self.cols, self.vals, self.labels, self.weight, self.penalty, 10000, 0) expected = np.repeat(2/3, self.n) diff = np.linalg.norm(self.weight - expected) self.assertLessEqual(diff, 1e-6, '|w* - w|') self.assertAlmostEqual(g, 0, delta=1e-6, msg='|grad|')
def steepest(self, penalty, maxiter=100000, gnormopt=0.01): watch = StopWatch() with watch: (f, g, i) = steepest(self.rows, self.cols, self.vals, self.labels, self.weight, penalty, maxiter, gnormopt) return RunResult('reference sd', i, watch.total_seconds, penalty, f, g)