def test_batch_idx_with_none(self, init_optimizer):
     scheduler = CyclicLR(init_optimizer)
     scheduler.batch_step()
     assert scheduler.last_batch_idx == 0
Example #2
0
 def test_invalid_number_of_max_lr(self, init_optimizer):
     with pytest.raises(ValueError):
         CyclicLR(init_optimizer, max_lr=[1, 2])
Example #3
0
    def test_scale_fn(self, init_optimizer):
        def scale_fn(x):
            return x

        scheduler = CyclicLR(init_optimizer, scale_fn=scale_fn)
        assert scheduler.scale_fn == scale_fn
Example #4
0
 def test_batch_idx_with_none(self, init_optimizer):
     scheduler = CyclicLR(init_optimizer)
     scheduler.batch_step()
     assert scheduler.last_batch_idx == 0
Example #5
0
 def test_invalid_not_a_optimizer(self):
     with pytest.raises(TypeError):
         CyclicLR('this is a string')
Example #6
0
 def test_invalid_mode(self, init_optimizer):
     with pytest.raises(ValueError):
         CyclicLR(init_optimizer, mode='badmode')
Example #7
0
 def test_triangular_mode(self, init_optimizer, num_groups):
     target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3]
     targets = [target] * num_groups
     scheduler = CyclicLR(init_optimizer, base_lr=1, max_lr=5, step_size_up=4,
                          mode='triangular')
     self._test_cycle_lr(init_optimizer, scheduler, targets)