Example #1
0
    def test_learning_rate_value(self):
        lr = -1.0
        with pytest.raises(ValueError):
            lr_schedules.ExponentialDecayLR(lr, decay_rate, decay_steps)

        with pytest.raises(ValueError):
            lr_schedules.PolynomialDecayLR(lr, end_learning_rate, decay_steps,
                                           power)
Example #2
0
    def test_learning_rate_type(self):
        lr = True
        with pytest.raises(TypeError):
            lr_schedules.ExponentialDecayLR(lr, decay_rate, decay_steps)

        with pytest.raises(TypeError):
            lr_schedules.PolynomialDecayLR(lr, end_learning_rate, decay_steps,
                                           power)
Example #3
0
    def test_decay_steps_value(self):
        decay_steps_e = -2
        with pytest.raises(ValueError):
            lr_schedules.ExponentialDecayLR(learning_rate, decay_rate,
                                            decay_steps_e)

        with pytest.raises(ValueError):
            lr_schedules.CosineDecayLR(min_lr, max_lr, decay_steps_e)

        with pytest.raises(ValueError):
            lr_schedules.PolynomialDecayLR(learning_rate, end_learning_rate,
                                           decay_steps_e, power)
Example #4
0
 def test_decay_rate_value(self):
     rate = -1.0
     with pytest.raises(ValueError):
         lr_schedules.ExponentialDecayLR(learning_rate, rate, decay_steps)
Example #5
0
 def test_decay_rate_type(self):
     rate = 'a'
     with pytest.raises(TypeError):
         lr_schedules.ExponentialDecayLR(learning_rate, rate, decay_steps)
Example #6
0
def test_exponential_decay():
    lr_schedule = lr_schedules.ExponentialDecayLR(learning_rate, decay_rate,
                                                  decay_steps, True)
    _executor.compile(lr_schedule, global_step)
Example #7
0
 def test_is_stair(self):
     is_stair = 1
     with pytest.raises(TypeError):
         lr_schedules.ExponentialDecayLR(learning_rate, decay_rate,
                                         decay_steps, is_stair)