Beispiel #1
0
 def train(self,
           n_episodes,
           noisy_policy_parameters=True,
           goal=None,
           **kwargs):
     if goal is None:
         str = "Training for {} episodes with random goals".format(
             n_episodes)
     else:
         str = "Training for {} episodes on the goal {}".format(
             n_episodes, goal)
     print_info(str)
     return (self._run(n_episodes,
                       train=True,
                       goal=goal,
                       noisy_policy_parameters=noisy_policy_parameters,
                       **kwargs))
Beispiel #2
0
    def bootstrap(self,
                  n_bootstrap,
                  save_to_replay_buffer=False,
                  noisy_action=False,
                  render=False):
        print_info("Bootstrapping: Motor babbling...")
        if n_bootstrap <= 0:
            raise (ValueError("0 bootstrap epoch selected, select at least 1"))

        for epoch, m in enumerate(
                self.environment.random_motors(n=n_bootstrap)):
            s, _ = self.environment.compute_sensori_effect(
                m,
                save_to_replay_buffer=save_to_replay_buffer,
                noisy_action=noisy_action,
                render=render,
                hooks=self.hooks)
            print("Iteration {}/{}. Achievement: {}".format(
                epoch + 1, n_bootstrap, s))
            self.model.update(m, s)
Beispiel #3
0
    def experiments(self, number, script_function, nb_processes=16):
        """Execute the given function in different subprocesses"""
        print_info("Beginning {} experiments".format(number))

        for experiment_count in range(1, number + 1):
            print_info("Spinning experiment {}/{}".format(
                experiment_count, number))
            experiment_id = str(experiment_count)
            experiment_id_full = (self.name + "/" + experiment_id)

            experiment = Experiment(experiment_id=experiment_id_full,
                                    experiments=self,
                                    path=self._path,
                                    hooks=[ExperimentArrayHook()])

            # Run the experiment in a separate process
            experiment_process = multiprocessing.Process(
                name=experiment_id,
                target=experiment_function,
                args=(script_function, experiment))
            experiment_process.start()