Пример #1
0
    def get_params(self, scope=''):
        return self.get_global_params(scope)

    def set_global_params(self, params, scope=''):
        params = [param[1] for param in params]
        self._Q = params[0]

    def set_params(self, params, scope=''):
        self.set_global_params(params, scope)


if __name__ == '__main__':
    from config import basic_configure

    config = basic_configure()

    task_selector = config['task_selector_fn'][0](
        **config['task_selector_fn'][1])
    '''
    import dill
    from tensorboardX import SummaryWriter

    summary_writer = SummaryWriter('/tmp/tf_board')

    tasks_specs = [
        dict(
            id=0,
            mg=range(0,2),
            g_dim=2,
            th=0.5,
Пример #2
0
Файл: task.py Проект: s-bl/cwyc
        else:
            raise NotImplementedError

        return np.asarray([reward]), np.asarray([done]), np.asarray([success])

    def get_global_params(self, scope=''):
        return (self._scope, [('success_rate', self.success_rate),
                              ('abs_success_rate_deriv',
                               self.abs_success_rate_deriv)])

    def get_params(self, scope=''):
        return self.get_global_params(scope)

    def set_global_params(self, params, scope=''):
        params = [param[1] for param in params]
        self.success_rate = params[0]
        self.abs_success_rate_deriv = params[1]

    def set_params(self, params, scope=''):
        self.set_global_params(params, scope)


if __name__ == '__main__':
    from config import basic_configure

    basic_config = basic_configure(logdir='/tmp/test', clean=True)

    tasks_fn = basic_config['tasks_fn']

    [task_fn[0](**task_fn[1]) for task_fn in tasks_fn]
Пример #3
0
        return episode, info


if __name__ == '__main__':
    from config import basic_configure
    from copy import deepcopy
    from functools import partial

    params = dict(
        experiment=
        '/is/sg/sblaes/research/repositories/public/rec_center/experiments/CWYC/experiments/boxes/sac_json',
        json_string='{"jobdir":"/tmp/notebook1"}')

    basic_conf, modules_fn, \
    summary_writer = basic_configure(**params)

    rollout_worker_fn = modules_fn['rollout_worker_fn']
    params = deepcopy(modules_fn)
    del params['rollout_worker_fn']
    rollout_worker_fn[1]['discard_modules_buffer'] = False
    rollout_worker = rollout_worker_fn[0](0,
                                          env_spec=basic_conf['env_spec'],
                                          **params,
                                          **rollout_worker_fn[1])

    # prefix = '950'
    # params = []
    # path = '/is/sg/sblaes/research/repositories/public/rec_center/results/CWYC/boxes/one_task/cwyc/'
    # for module in rollout_worker._tasks + rollout_worker._policies + [rollout_worker._gnets[i][j] for i in
    #                                                                   range(len(rollout_worker._gnets)) for j in
Пример #4
0
        self._buffer['transitions_time'].extend(transition_time)
        self._buffer['surprises'].extend(surprises)


if __name__ == '__main__':
    import dill
    from config import basic_configure
    from copy import deepcopy
    from functools import partial

    params = dict(
        experiment=
        '/local_data/sblaes/research/phd/repositories/public/rec_center/experiments/CWYC/experiments/pickandplace/three_task_her_json',
        json_string='{"jobdir":"/tmp/test"}')

    basic_conf, modules_fn, summary_writer = basic_configure(**params)

    rollout_worker_fn = modules_fn['rollout_worker_fn']
    params = deepcopy(modules_fn)
    del params['rollout_worker_fn']
    rollout_worker = rollout_worker_fn[0](0,
                                          env_spec=basic_conf['env_spec'],
                                          **params,
                                          **rollout_worker_fn[1])

    prefix = 'latest'
    params = []
    for module in rollout_worker._tasks + rollout_worker._policies + [rollout_worker._gnets[i][j] for i in
                                                                      range(len(rollout_worker._gnets)) for j in
                                                                      range(len(rollout_worker._gnets))] + \
                  [rollout_worker._task_selector, rollout_worker._task_planner, rollout_worker._forward_model]:
Пример #5
0
                module, val = key.split('/')
                assert module in self._train_res and val in self._train_res[
                    module]
                self._write_data(key, self._train_res[module][val][0],
                                 self._train_res[module][val][1], ep, env_step)

    def __del__(self):
        for remote in self._remotes:
            remote.send(('quit', None))


if __name__ == '__main__':
    from config import basic_configure
    from multiprocessing import Manager

    basic_conf = basic_configure(jobdir='/tmp/test', clean=True)

    env_spec = basic_conf['env_spec']
    T = env_spec['T']
    env_fn = basic_conf['env_fn']
    tasks_fn = basic_conf['tasks_fn']
    policies_fn = basic_conf['policies_fn']
    gnets_fn = basic_conf['gnets_fn']
    task_selector_fn = basic_conf['task_selector_fn']
    task_planner_fn = basic_conf['task_planner_fn']
    forward_model_fn = basic_conf['forward_model_fn']
    rollout_worker_fn = basic_conf['rollout_worker_fn']
    summary_writer = basic_conf['summary_writer']

    manager = Manager()
    episode = manager.dict()