Ejemplo n.º 1
0
 def test_nonpositive_transition_steps(self):
     with self.assertRaises(ValueError):
         schedule.cosine_onecycle_schedule(transition_steps=0,
                                           peak_value=5.)
     with self.assertRaises(ValueError):
         schedule.linear_onecycle_schedule(transition_steps=0,
                                           peak_value=5.)
Ejemplo n.º 2
0
    def test_linear(self):
        schedule_fn = self.variant(
            schedule.linear_onecycle_schedule(transition_steps=10,
                                              peak_value=1000,
                                              pct_start=0.3,
                                              pct_final=0.7,
                                              div_factor=10.,
                                              final_div_factor=100.))

        generated_vals = [schedule_fn(step) for step in range(12)]
        expected_vals = [
            100., 400., 700., 1000., 775., 550., 325., 100., 67., 34., 1., 1.
        ]
        np.testing.assert_allclose(generated_vals, expected_vals, atol=1e-3)