Exemple #1
0
 def test_ddpg_workflow(self):
     """Run DDPG workflow to ensure no crashes, algorithm correctness
     not tested here."""
     params = {
         "training_data_path":
         os.path.join(
             curr_dir,
             "test_data/continuous_action/pendulum_training_data.json"),
         "state_norm_data_path":
         os.path.join(
             curr_dir,
             "test_data/continuous_action/state_features_norm.json"),
         "action_norm_data_path":
         os.path.join(curr_dir,
                      "test_data/continuous_action/action_norm.json"),
         "model_output_path":
         None,
         "use_gpu":
         False,
         "epochs":
         1,
         "rl": {},
         "rainbow": {},
         "shared_training": {
             "minibatch_size": 16
         },
         "actor_training": {},
         "critic_training": {},
     }
     predictor = ddpg_workflow.train_network(params)
     test_float_state_features = [{"0": 1.0, "1": 1.0, "2": 1.0, "3": 1.0}]
     test_int_state_features = [{}]
     action = predictor.actor_prediction(test_float_state_features,
                                         test_int_state_features)
     assert len(action) == 1
Exemple #2
0
 def _test_ddpg_workflow(self, use_gpu=False, use_all_avail_gpus=False):
     """Run DDPG workflow to ensure no crashes, algorithm correctness
     not tested here."""
     with tempfile.TemporaryDirectory() as tmpdirname:
         params = {
             "training_data_path": os.path.join(
                 curr_dir, "test_data/continuous_action/pendulum_training.json.bz2"
             ),
             "eval_data_path": os.path.join(
                 curr_dir, "test_data/continuous_action/pendulum_eval.json.bz2"
             ),
             "state_norm_data_path": os.path.join(
                 curr_dir, "test_data/continuous_action/state_features_norm.json"
             ),
             "action_norm_data_path": os.path.join(
                 curr_dir, "test_data/continuous_action/action_norm.json"
             ),
             "model_output_path": tmpdirname,
             "use_gpu": use_gpu,
             "use_all_avail_gpus": use_all_avail_gpus,
             "epochs": 1,
             "rl": {},
             "rainbow": {},
             "shared_training": {"minibatch_size": 128},
             "actor_training": {},
             "critic_training": {},
         }
         predictor = ddpg_workflow.train_network(params)
         test_float_state_features = [{"0": 1.0, "1": 1.0, "2": 1.0, "3": 1.0}]
         test_int_state_features = [{}]
         action = predictor.actor_prediction(
             test_float_state_features, test_int_state_features
         )
     assert len(action) == 1