Beispiel #1
0
 def setUpClass(cls):
     cls.parser = apex_argument()
     cls.parser.set_defaults(n_training=10)
     cls.parser.set_defaults(param_update_freq=1)
     cls.parser.set_defaults(test_freq=10)
     cls.parser.set_defaults(n_explorer=2)
     cls.parser.set_defaults(n_env=4)
     cls.parser.set_defaults(local_buffer_size=64)
Beispiel #2
0
def test_run(parser):
    parser = apex_argument()
    parser.set_defaults(n_training=10)
    parser.set_defaults(param_update_freq=1)
    parser.set_defaults(test_freq=10)
    parser.set_defaults(n_env=64)
    parser.set_defaults(local_buffer_size=64)

    _test_run_discrete(parser)
    _test_run_continuous(parser)
Beispiel #3
0
                critic_units=[400, 300],
                memory_capacity=memory_capacity)


def get_weights_fn(policy):
    # TODO: Check if following needed
    import tensorflow as tf
    with tf.device(policy.device):
        return [
            policy.actor.weights, policy.critic.weights,
            policy.critic_target.weights
        ]


def set_weights_fn(policy, weights):
    actor_weights, critic_weights, critic_target_weights = weights
    update_target_variables(policy.actor.weights, actor_weights, tau=1.)
    update_target_variables(policy.critic.weights, critic_weights, tau=1.)
    update_target_variables(policy.critic_target.weights,
                            critic_target_weights,
                            tau=1.)


if __name__ == '__main__':
    parser = apex_argument()
    parser.add_argument('--env-name', type=str, default="Pendulum-v0")
    parser = DDPG.get_argument(parser)
    args = parser.parse_args()

    run(args, env_fn(args.env_name), policy_fn, get_weights_fn, set_weights_fn)