コード例 #1
0
 def test_rescales_control(self):
     config = ("weight_decay", None, (1e-5, 0.1), False)
     controls = np.array([4e-4, 3e-3, 2e-2])
     (obs_low, obs_high) = (103, 104)
     obs = online_tune.control_to_observation(
         controls,
         config,
         observation_range=(obs_low, obs_high),
     )
     np.testing.assert_array_less(obs, [obs_high] * 3)
     np.testing.assert_array_less([obs_low] * 3, obs)
コード例 #2
0
 def test_clips_control_with_flipping(self):
     config = ("momentum", None, (0.5, 0.99), True)
     controls = np.array([0.4, 1.0])
     obs_range = (-1, 1)
     obs = online_tune.control_to_observation(controls, config, obs_range)
     np.testing.assert_equal(obs, [1, -1])
コード例 #3
0
 def test_converts_control_to_log_scale_with_flipping(self):
     config = ("momentum", None, (0.5, 0.99), True)
     controls = np.array([0.98, 0.96, 0.92])
     obs_range = (-1, 1)
     obs = online_tune.control_to_observation(controls, config, obs_range)
     np.testing.assert_almost_equal(obs[1] - obs[0], obs[2] - obs[1])
コード例 #4
0
 def test_clips_control_without_flipping(self):
     config = ("weight_decay", None, (1e-5, 0.1), False)
     controls = np.array([0.0, 0.2])
     obs_range = (-1, 1)
     obs = online_tune.control_to_observation(controls, config, obs_range)
     np.testing.assert_equal(obs, [-1, 1])
コード例 #5
0
 def test_converts_control_to_log_scale_without_flipping(self):
     config = ("weight_decay", None, (1e-5, 0.1), False)
     controls = np.array([0.01, 0.02, 0.04])
     obs_range = (-1, 1)
     obs = online_tune.control_to_observation(controls, config, obs_range)
     np.testing.assert_almost_equal(obs[1] - obs[0], obs[2] - obs[1])