예제 #1
0
 def load_policies(self, folder) -> None:
     """
      :param: folder : name of the folder containing policies
      Output : none (policies of the folder stored in self.env_dict)        
      """
     listdir = os.listdir(folder)
     for policy_file in listdir:
         print(policy_file)
         pw = PolicyWrapper(GenericNet(), "", "", "", 0)
         policy = pw.load(folder + policy_file)
         if pw.env_name in self.env_dict:
             env = make_env(pw.env_name, pw.policy_type, pw.max_steps)
             env.set_reward_flag(False)
             env.set_duration_flag(False)
             scores = evaluate_pol(env, policy, False)
             self.score_dict[pw.env_name][scores.mean()] = [
                 pw.team_name, scores.std()
             ]
         else:
             env = make_env(pw.env_name, pw.policy_type, pw.max_steps)
             env.set_reward_flag(False)
             env.set_duration_flag(False)
             self.env_dict[pw.env_name] = env
             scores = evaluate_pol(env, policy, False)
             tmp_score_dict = {scores.mean(): [pw.team_name, scores.std()]}
             self.score_dict[pw.env_name] = tmp_score_dict
예제 #2
0
def load_policies(folder):
    """
     :param: folder : name of the folder containing policies
     Output : none (policies of the folder stored in self.env_dict)
     """
    listdir = os.listdir(folder)
    policies = []
    for policy_file in listdir:
        pw = PolicyWrapper(GenericNet(), 0, "", "", "", 0)
        policy,_ = pw.load(directory+policy_file)
        policy = policy.get_weights()
        policies.append(policy)
    return policies