Ejemplo n.º 1
0
 def setUp(self):
     steps = 2
     phases = [
         Phase(lr=linspace(0, 0, steps)),
         Phase(lr=linspace(1, 1, steps)),
         Phase(lr=linspace(2, 2, steps)),
     ]
     self.policy = OptimizerPolicy(phases=phases, initial_step=3)
Ejemplo n.º 2
0
 def test_phase_with_only_one_parameter_set(self):
     for param_name in ["lr", "momentum"]:
         steps = 3
         phase = Phase(**{param_name: linspace(1, 0, steps)})
         for params in phase:
             self.assertIsInstance(params, dict)
             self.assertTrue(param_name in params)
             self.assertEqual(len(params), 1)
             self.assertTrue(0 <= params[param_name] <= 1)
Ejemplo n.º 3
0
    def test_phase_with_two_parameters(self):
        steps = 4
        phase = Phase(lr=linspace(1, 0, steps), momentum=cosinespace(.8, 1, steps))
        self.assertEqual(len(list(phase)), steps)
        for params in phase:
            self.assertEqual(len(params), 2)

            self.assertTrue("lr" in params)
            self.assertTrue(0 <= params["lr"] <= 1)

            self.assertTrue("momentum" in params)
            self.assertTrue(.8 <= params["momentum"] <= 1)
Ejemplo n.º 4
0
 def setUp(self):
     steps = 2
     phases = [Phase(lr=linspace(1, 1, steps)), Phase(lr=linspace(0, 0, steps))]
     self.policy = OptimizerPolicy(phases)
Ejemplo n.º 5
0
 def test_linspace_with_many_values(self):
     self.assert_space(linspace(0, 1, 6), [0, .2, .4, .6, .8, 1])
Ejemplo n.º 6
0
 def test_linspace_decreasing(self):
     self.assert_space(linspace(1, 0, 3), [1, .5, 0])
Ejemplo n.º 7
0
 def test_linspace_increasing(self):
     self.assert_space(linspace(0, 1, 3), [0, .5, 1])
Ejemplo n.º 8
0
 def test_linspace_const(self):
     self.assert_space(linspace(0, 0, 3), [0, 0, 0])