Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_length_with_higher_cycle_mult(self):
policy = OptimizerPolicy(sgdr_phases(10, 1, cycle_mult=2))
self.assertEqual(len(list(policy.all_steps())), 10)
policy = OptimizerPolicy(sgdr_phases(10, 2, cycle_mult=2))
self.assertEqual(len(list(policy.all_steps())), 30)
policy = OptimizerPolicy(sgdr_phases(10, 3, cycle_mult=2))
self.assertEqual(len(list(policy.all_steps())), 70)
policy = OptimizerPolicy(sgdr_phases(10, 1, cycle_mult=3))
self.assertEqual(len(list(policy.all_steps())), 10)
policy = OptimizerPolicy(sgdr_phases(10, 2, cycle_mult=3))
self.assertEqual(len(list(policy.all_steps())), 40)
def test_length_with_cycle_mult_one(self):
policy = OptimizerPolicy(sgdr_phases(10, 1, cycle_mult=1))
self.assertEqual(len(list(policy.all_steps())), 10)
policy = OptimizerPolicy(sgdr_phases(10, 2, cycle_mult=1))
self.assertEqual(len(list(policy.all_steps())), 20)
policy = OptimizerPolicy(sgdr_phases(10, 10, cycle_mult=1))
self.assertEqual(len(list(policy.all_steps())), 100)
def test_length(self):
policy = OptimizerPolicy(one_cycle_phases(100))
self.assertEqual(len(list(policy.all_steps())), 100)
policy = OptimizerPolicy(one_cycle_phases(99))
self.assertEqual(len(list(policy.all_steps())), 99)
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)
def setUp(self):
steps = 2
phases = [Phase(lr=linspace(1, 1, steps)), Phase(lr=linspace(0, 0, steps))]
self.policy = OptimizerPolicy(phases)