-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect_demo.py
46 lines (39 loc) · 1.27 KB
/
collect_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import argparse
import torch
from gail_airl_ppo.env import make_env
from gail_airl_ppo.algo import SACExpert
from gail_airl_ppo.utils import collect_demo
def run(args):
env = make_env(args.env_id)
algo = SACExpert(
state_shape=env.observation_space.shape,
action_shape=env.action_space.shape,
device=torch.device("cuda" if args.cuda else "cpu"),
path=args.weight
)
buffer = collect_demo(
env=env,
algo=algo,
buffer_size=args.buffer_size,
device=torch.device("cuda" if args.cuda else "cpu"),
std=args.std,
p_rand=args.p_rand,
seed=args.seed
)
buffer.save(os.path.join(
'buffers',
args.env_id,
f'size{args.buffer_size}_std{args.std}_prand{args.p_rand}.pth'
))
if __name__ == '__main__':
p = argparse.ArgumentParser()
p.add_argument('--weight', type=str, required=True)
p.add_argument('--env_id', type=str, default='Hopper-v3')
p.add_argument('--buffer_size', type=int, default=10**6)
p.add_argument('--std', type=float, default=0.0)
p.add_argument('--p_rand', type=float, default=0.0)
p.add_argument('--cuda', action='store_true')
p.add_argument('--seed', type=int, default=0)
args = p.parse_args()
run(args)