Beispiel #1
0
    def ohe_test(self, scores, episode_numbers):
        """
        method runs 100 testing episodes
        """
        complete_estimation = agent_score_estimate(self, 10)
        if complete_estimation >= self.solved_score:
            for i in range(2, 11):
                estimation = agent_score_estimate(self, 10)
                complete_estimation = complete_estimation + estimation
                if (complete_estimation / i) < self.solved_score:
                    return
        else:
            return
        score = complete_estimation / 10

        if score > self.solved_score:
            if not self.args.dont_save:
                self.agent.save_model_weights("{}-solved.h5" .format(self.name))
                combined_graph(scores, episode_numbers, "{}_results" .format(self.name),
                               [episode_numbers[-1], max(scores)+10], {self.average_rand_score:self.average_rand_score}, scatter=True)
            if self.solved_score <= score:
                print("[Task was solved after {} episodes with score {}.]" .format(episode_numbers[-1], score))
            else:
                print("[Task wasn't solved after {} episodes with score {}.]" .format(episode_numbers[-1], score))
            print("[SUCCESSFUL RUN]")
            K.clear_session()
            sys.exit()
Beispiel #2
0
 def aohe_test(self, scores, episode_numbers):
     """
     method runs 100 testing episodes after 100 training episodes
     """
     if episode_numbers[-1] == 99:
         score = agent_score_estimate(self, 100)
         self.agent.save_model_weights("{}-solved.h5" .format(self.name))
         combined_graph(scores, episode_numbers, "{}_results" .format(self.name), 
                        [episode_numbers[-1], max(scores)+10], {self.average_rand_score:self.average_rand_score}, scatter=True)
         print("[Task was solved after {} episodes with score {}.]" .format(episode_numbers[-1], score))
         print("[SUCCESSFUL RUN]")
         K.clear_session()
         sys.exit()
Beispiel #3
0
    if task.args.mode == "train":
        task, true_scores, episodes_numbers, _, normalized_scores = train(
            task, True)
        task.agent.save_model_weights("{}-last.h5".format(task.name))
        task.agent.save_target_weights("{}-last.h5".format(task.name))
        try:
            combined_graph(true_scores, episodes_numbers,
                           "{}_results".format(task.name),
                           [episodes_numbers[-1] + 10,
                            max(true_scores) + 10],
                           {task.average_rand_score: task.average_rand_score},
                           True)
        except ValueError:
            err_print("[Not enough values to make graph.]")

    elif task.args.mode == "test":
        agent_score_estimate(task,
                             task.args.episodes,
                             render=False,
                             show_bar=True)

    elif task.args.mode == "render":
        agent_score_estimate(task,
                             task.args.episodes,
                             render=True,
                             show_bar=True)

    K.clear_session()
    print("[SUCCESSFUL RUN]")