-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathRL_Mirror_Supervised.py
653 lines (561 loc) · 25.1 KB
/
RL_Mirror_Supervised.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
import argparse
import os
import sys
import random
import numpy as np
import scipy
import torch
import torch.optim as optim
import torch.multiprocessing as mp
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.utils.data
from params import Params
import pickle
import time as t
from model import ActorCriticNet, Shared_obs_stats
import statistics
import matplotlib.pyplot as plt
from operator import add, sub
import pickle
import threading
import torch.multiprocessing as mp
import queue
from random import randint
from cassie_env.cassieRLEnvMirror import cassieRLEnvMirror
from cassie_env.cassieRLEnvMirrorIKTraj import cassieRLEnvMirrorIKTraj
from utils import TrafficLight
from utils import Counter
class ReplayMemory(object):
def __init__(self, capacity):
self.capacity = capacity
self.memory = []
def push(self, events):
for event in zip(*events):
self.memory.append(event)
if len(self.memory)>self.capacity:
del self.memory[0]
def push_half(self, events):
temp_memory = []
for event in zip(*events):
temp_memory.append(event)
self.memory = self.memory + temp_memory[0:len(temp_memory)//2]
while len(self.memory)>self.capacity:
del self.memory[0]
def clear(self):
self.memory = []
def sample(self, batch_size):
samples = zip(*random.sample(self.memory, batch_size))
#print(map(lambda x: np.concatenate(x, 0), samples))
return map(lambda x: np.concatenate(x, 0), samples)
def normal(x, mu, log_std):
a = (x - mu)/(log_std.exp().to(device))
a = -0.5 * a.pow(2)
a = torch.sum(a, dim=1)
b = torch.sum(log_std.to(device), dim=1)
#print(result)
return a-b
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# device = torch.device("cpu")
class RL(object):
def __init__(self, env, hidden_layer=[64, 64]):
self.env = env
#self.env.env.disableViewer = False
self.num_inputs = env.observation_space.shape[0]
self.num_outputs = env.action_space.shape[0]
self.hidden_layer = hidden_layer
self.params = Params()
self.model = ActorCriticNet(self.num_inputs, self.num_outputs,self.hidden_layer)
self.gpu_model = ActorCriticNet(self.num_inputs, self.num_outputs, self.hidden_layer).to(device)
self.shared_obs_stats = Shared_obs_stats(self.num_inputs)
self.best_model = ActorCriticNet(self.num_inputs, self.num_outputs,self.hidden_layer)
self.memory = ReplayMemory(self.params.num_steps * 10000)
self.test_mean = []
self.test_std = []
self.noisy_test_mean = []
self.noisy_test_std = []
self.fig = plt.figure()
#self.fig2 = plt.figure()
self.lr = self.params.lr
plt.show(block=False)
self.test_list = []
self.noisy_test_list = []
self.queue = mp.Queue()
self.mpdone = [mp.Event(), mp.Event(), mp.Event(), mp.Event()]
self.process = []
self.traffic_light = TrafficLight()
self.counter = Counter()
self.best_trajectory = ReplayMemory(300)
self.best_score_queue = mp.Queue()
self.best_score = mp.Value("f", 0)
self.expert_trajectory = ReplayMemory(600000)
self.validation_trajectory = ReplayMemory(6000*9)
self.best_validation = 1.0
self.current_best_validation = 1.0
def normalize_data(self, num_iter=50000, file='shared_obs_stats.pkl'):
state = self.env.reset_for_normalization()
state = Variable(torch.Tensor(state).unsqueeze(0))
model_old = ActorCriticNet(self.num_inputs, self.num_outputs,self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
for i in range(num_iter):
self.shared_obs_stats.observes(state)
state = self.shared_obs_stats.normalize(state)
mu, log_std, v = model_old(state)
eps = torch.randn(mu.size())
action = (mu + log_std.exp()*Variable(eps))
env_action = action.data.squeeze().numpy()
state, reward, done, _ = self.env.step(env_action)
if done:
state = self.env.reset()
state = Variable(torch.Tensor(state).unsqueeze(0))
with open(file, 'wb') as output:
pickle.dump(self.shared_obs_stats, output, pickle.HIGHEST_PROTOCOL)
def run_test(self, num_test=1):
state = self.env.reset_for_test()
state = Variable(torch.Tensor(state).unsqueeze(0))
model_old = ActorCriticNet(self.num_inputs, self.num_outputs,self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
ave_test_reward = 0
total_rewards = []
'''self.fig2.clear()
circle1 = plt.Circle((0, 0), 0.5, edgecolor='r', facecolor='none')
circle2 = plt.Circle((0, 0), 0.01, edgecolor='r', facecolor='none')
plt.axis('equal')'''
for i in range(num_test):
total_reward = 0
while True:
state = self.shared_obs_stats.normalize(state)
mu, log_std, v = self.model(state)
action = mu.data.squeeze().numpy()
state, reward, done, _ = self.env.step(action)
total_reward += reward
#print(state)
#print("done", done, "state", state)
if done:
state = self.env.reset_for_test()
#print(self.env.position)
#print(self.env.time)
state = Variable(torch.Tensor(state).unsqueeze(0))
ave_test_reward += total_reward / num_test
total_rewards.append(total_reward)
break
state = Variable(torch.Tensor(state).unsqueeze(0))
#print("avg test reward is", ave_test_reward)
reward_mean = statistics.mean(total_rewards)
reward_std = statistics.stdev(total_rewards)
self.test_mean.append(reward_mean)
self.test_std.append(reward_std)
self.test_list.append((reward_mean, reward_std))
#print(self.model.state_dict())
def run_test_with_noise(self, num_test=10):
state = self.env.reset_for_test()
state = Variable(torch.Tensor(state).unsqueeze(0))
model_old = ActorCriticNet(self.num_inputs, self.num_outputs,self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
ave_test_reward = 0
total_rewards = []
'''self.fig2.clear()
circle1 = plt.Circle((0, 0), 0.5, edgecolor='r', facecolor='none')
circle2 = plt.Circle((0, 0), 0.01, edgecolor='r', facecolor='none')
plt.axis('equal')'''
for i in range(num_test):
total_reward = 0
while True:
state = self.shared_obs_stats.normalize(state)
mu, log_std, v = self.model(state)
eps = torch.randn(mu.size())
action = (mu + 0.1*Variable(eps))
action = action.data.squeeze().numpy()
state, reward, done, _ = self.env.step(action)
total_reward += reward
if done:
state = self.env.reset_for_test()
state = Variable(torch.Tensor(state).unsqueeze(0))
ave_test_reward += total_reward / num_test
total_rewards.append(total_reward)
break
state = Variable(torch.Tensor(state).unsqueeze(0))
#print("avg test reward is", ave_test_reward)
reward_mean = statistics.mean(total_rewards)
reward_std = statistics.stdev(total_rewards)
self.noisy_test_mean.append(reward_mean)
self.noisy_test_std.append(reward_std)
self.noisy_test_list.append((reward_mean, reward_std))
def plot_statistics(self):
ax = self.fig.add_subplot(121)
ax2 = self.fig.add_subplot(122)
low = []
high = []
index = []
noisy_low = []
noisy_high = []
for i in range(len(self.test_mean)):
low.append(self.test_mean[i] - self.test_std[i])
high.append(self.test_mean[i] + self.test_std[i])
noisy_low.append(self.noisy_test_mean[i]-self.noisy_test_std[i])
noisy_high.append(self.noisy_test_mean[i]+self.noisy_test_std[i])
index.append(i)
#ax.set_xlim([0,1000])
#ax.set_ylim([0,300])
plt.xlabel('iterations')
plt.ylabel('average rewards')
ax.plot(self.test_mean, 'b')
ax2.plot(self.noisy_test_mean, 'g')
ax.fill_between(index, low, high, color='cyan')
ax2.fill_between(index, noisy_low, noisy_high, color='r')
#ax.plot(map(sub, test_mean, test_std))
self.fig.canvas.draw()
#plt.draw()
#plt.errorbar(self.test_mean)
def collect_samples(self, num_samples, start_state=None, noise=-2.0, env_index=0, random_seed=1):
random.seed(random_seed)
torch.manual_seed(random_seed+1)
np.random.seed(random_seed+2)
if start_state == None:
start_state = self.env.reset()
samples = 0
done = False
states = []
next_states = []
actions = []
rewards = []
values = []
q_values = []
self.model.set_noise(noise)
#print("soemthing 1")
model_old = ActorCriticNet(self.num_inputs, self.num_outputs, self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
#print("something 2")
model_old.set_noise(noise)
state = start_state
state = Variable(torch.Tensor(state).unsqueeze(0))
total_reward = 0
#q_value = Variable(torch.zeros(1, 1))
while True:
self.model.set_noise(-2.0)
model_old.set_noise(-2.0)
signal_init = self.traffic_light.get()
score = 0
while samples < num_samples and not done:
state = self.shared_obs_stats.normalize(state)
#print(state)
states.append(state.data.numpy())
mu, log_std, v = model_old(state)
eps = torch.randn(mu.size())
#print(log_std.exp())
action = (mu + log_std.exp()*Variable(eps))
actions.append(action.data.numpy())
values.append(v.data.numpy())
env_action = action.data.squeeze().numpy()
state, reward, done, _ = self.env.step(env_action)
score += reward
rewards.append(Variable(reward * torch.ones(1)).data.numpy())
#q_value = self.gamma * q_value + Variable(reward * torch.ones(1))
state = Variable(torch.Tensor(state).unsqueeze(0))
next_state = self.shared_obs_stats.normalize(state)
next_states.append(next_state.data.numpy())
samples += 1
state = self.shared_obs_stats.normalize(state)
#print(state)
_,_,v = model_old(state)
if done:
R = torch.zeros(1, 1)
else:
R = v.data
R = Variable(R)
for i in reversed(range(len(rewards))):
R = self.params.gamma * R + Variable(torch.from_numpy(rewards[i]))
q_values.insert(0, R.data.numpy())
#self.memory.push([states, actions, next_states, rewards, q_values])
#return [states, actions, next_states, rewards, q_values]
self.queue.put([states, actions, next_states, rewards, q_values])
#print(score)
'''if score >= self.best_score.value:
self.best_score.value = score
print("best score", self.best_score.value)
self.best_score_queue.put([states, actions, next_states, rewards, q_values])'''
self.counter.increment()
self.env.reset()
while self.traffic_light.get() == signal_init:
pass
start_state = self.env.reset()
state = start_state
state = Variable(torch.Tensor(state).unsqueeze(0))
total_reward = 0
samples = 0
done = False
states = []
next_states = []
actions = []
rewards = []
values = []
q_values = []
model_old = ActorCriticNet(self.num_inputs, self.num_outputs, self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
model_old.set_noise(-2.0)
def collect_expert_samples(self, num_samples, filename, noise=-2.0, speed=0, y_speed=0, validation=False):
expert_env = cassieRLEnvMirror()
start_state = expert_env.reset_by_speed(speed, y_speed)
samples = 0
done = False
states = []
next_states = []
actions = []
rewards = []
values = []
q_values = []
self.model.set_noise(noise)
model_expert = ActorCriticNet(85, 10, [256, 256])
model_expert.load_state_dict(torch.load(filename))
model_expert.set_noise(noise)
with open('torch_model/cassie3dMirror2kHz_shared_obs_stats.pkl', 'rb') as input:
expert_shared_obs_stats = pickle.load(input)
state = start_state
virtual_state = np.concatenate([np.copy(state[0:46]), np.zeros(39)])
state = Variable(torch.Tensor(state).unsqueeze(0))
virtual_state = Variable(torch.Tensor(virtual_state).unsqueeze(0))
total_reward = 0
total_sample = 0
#q_value = Variable(torch.zeros(1, 1))
if validation:
max_sample = 300
else:
max_sample = 600
while total_sample < max_sample:
model_expert.set_noise(-2.0)
score = 0
while samples < num_samples and not done:
state = expert_shared_obs_stats.normalize(state)
virtual_state = expert_shared_obs_stats.normalize(virtual_state)
states.append(state.data.numpy())
mu, log_std, v = model_expert(state)
#print(log_std.exp())
action = mu
actions.append(action.data.numpy())
values.append(v.data.numpy())
eps = torch.randn(mu.size())
if validation:
weight = 0.1
else:
weight = 0.1
mu = (action + weight*Variable(eps))
env_action = mu.data.squeeze().numpy()
state, reward, done, _ = expert_env.step(env_action)
reward = 1
rewards.append(Variable(reward * torch.ones(1)).data.numpy())
#q_value = self.gamma * q_value + Variable(reward * torch.ones(1))
virtual_state = np.concatenate([np.copy(state[0:46]), np.zeros(39)])
virtual_state = Variable(torch.Tensor(virtual_state).unsqueeze(0))
state = Variable(torch.Tensor(state).unsqueeze(0))
next_state = expert_shared_obs_stats.normalize(state)
next_states.append(next_state.data.numpy())
samples += 1
#total_sample += 1
score += reward
print("expert score", score)
state = expert_shared_obs_stats.normalize(state)
#print(state)
_,_,v = model_expert(state)
if done:
R = torch.zeros(1, 1)
else:
R = v.data
R = torch.ones(1, 1) * 100
R = Variable(R)
for i in reversed(range(len(rewards))):
R = self.params.gamma * R + Variable(torch.from_numpy(rewards[i]))
q_values.insert(0, R.data.numpy())
if not validation and score >= 299:
self.expert_trajectory.push([states, actions, next_states, rewards, q_values])
total_sample += 300
elif score >= 299:
self.validation_trajectory.push([states, actions, next_states, rewards, q_values])
expert_env.reset_by_speed(speed, y_speed)
start_state = expert_env.reset_by_speed(speed, y_speed)
state = start_state
state = Variable(torch.Tensor(state).unsqueeze(0))
total_reward = 0
samples = 0
done = False
states = []
next_states = []
actions = []
rewards = []
values = []
q_values = []
def update_critic(self, batch_size, num_epoch):
self.gpu_model.load_state_dict(self.model.state_dict())
self.gpu_model.train()
self.gpu_model.set_noise(self.model.noise)
optimizer = optim.Adam(self.gpu_model.parameters(), lr=self.lr*10)
for k in range(num_epoch):
batch_states, batch_actions, batch_next_states, batch_rewards, batch_q_values = self.memory.sample(batch_size)
batch_states = torch.Tensor(batch_states).to(device)
batch_q_values = torch.Tensor(batch_q_values).to(device)
batch_next_states = torch.Tensor(batch_next_states).to(device)
_, _, v_pred = self.gpu_model(batch_states)
loss_value = (v_pred - batch_q_values)**2
#loss_value = (v_pred_next * self.params.gamma + batch_rewards - v_pred)**2
loss_value = 0.5*torch.mean(loss_value)
optimizer.zero_grad()
loss_value.backward(retain_graph=True)
optimizer.step()
#av_value_loss = loss_value.data[0]
#model_old.load_state_dict(model.state_dict())
#print("value loss ", av_value_loss)
def update_actor(self, batch_size, num_epoch, supervised=False):
model_old = ActorCriticNet(self.num_inputs, self.num_outputs, self.hidden_layer).to(device)
model_old.load_state_dict(self.gpu_model.state_dict())
model_old.set_noise(self.gpu_model.noise)
self.gpu_model.train()
optimizer = optim.Adam(self.gpu_model.parameters(), lr=self.lr)
for k in range(num_epoch):
batch_states, batch_actions, batch_next_states, batch_rewards, batch_q_values = self.memory.sample(batch_size)
batch_states = torch.Tensor(batch_states).to(device)
batch_q_values = torch.Tensor(batch_q_values).to(device)
batch_actions = torch.Tensor(batch_actions).to(device)
mu_old, log_std_old, v_pred_old = model_old(batch_states)
#mu_old_next, log_std_old_next, v_pred_old_next = model_old(batch_next_states)
mu, log_std, v_pred = self.gpu_model(batch_states)
batch_advantages = batch_q_values - v_pred_old
probs_old = normal(batch_actions, mu_old, log_std_old)
probs = normal(batch_actions, mu, log_std)
ratio = (probs - (probs_old)).exp()
ratio = ratio.unsqueeze(1)
#print(model_old.noise)
#print(ratio)
batch_advantages = batch_q_values - v_pred_old
surr1 = ratio * batch_advantages
surr2 = ratio.clamp(1-self.params.clip, 1+self.params.clip) * batch_advantages
loss_clip = -torch.mean(torch.min(surr1, surr2))
#expert loss
if supervised is True:
if k % 1000 == 999:
batch_expert_states, batch_expert_actions, _, _, _ = self.expert_trajectory.sample(len(self.expert_trajectory.memory))
else:
batch_expert_states, batch_expert_actions, _, _, _ = self.expert_trajectory.sample(batch_size)
batch_expert_states = Variable(torch.Tensor(batch_expert_states))
batch_expert_actions = Variable(torch.Tensor(batch_expert_actions))
mu_expert, _, _ = self.gpu_model(batch_expert_states)
mu_expert_old, _, _ = model_old(batch_expert_states)
loss_expert1 = torch.mean((batch_expert_actions-mu_expert)**2)
clip_expert_action = torch.max(torch.min(mu_expert, mu_expert_old + 0.1), mu_expert_old-0.1)
loss_expert2 = torch.mean((clip_expert_action-batch_expert_actions)**2)
loss_expert = loss_expert1#torch.min(loss_expert1, loss_expert2)
else:
loss_expert = 0
total_loss = self.policy_weight * loss_clip + self.weight*loss_expert
optimizer.zero_grad()
total_loss.backward(retain_graph=True)
#print(torch.nn.utils.clip_grad_norm(self.model.parameters(),1))
optimizer.step()
if self.lr > 1e-4:
self.lr *= 0.99
self.model.load_state_dict(self.gpu_model.state_dict())
def validation(self):
batch_states, batch_actions, batch_next_states, batch_rewards, batch_q_values = self.validation_trajectory.sample(300)
model_old = ActorCriticNet(self.num_inputs, self.num_outputs, self.hidden_layer)
model_old.load_state_dict(self.model.state_dict())
batch_states = Variable(torch.Tensor(batch_states))
batch_q_values = Variable(torch.Tensor(batch_q_values))
batch_actions = Variable(torch.Tensor(batch_actions))
mu_old, log_std_old, v_pred_old = model_old(batch_states)
loss = torch.mean((batch_actions-mu_old)**2)
if loss.data < self.current_best_validation:
self.current_best_validation = loss.data
print("validation error", self.current_best_validation)
def clear_memory(self):
self.memory.clear()
def save_model(self, filename):
torch.save(self.model.state_dict(), filename)
def save_shared_obs_stas(self, filename):
with open(filename, 'wb') as output:
pickle.dump(self.shared_obs_stats, output, pickle.HIGHEST_PROTOCOL)
def save_statistics(self, filename):
statistics = [self.noisy_test_mean, self.noisy_test_std]
with open(filename, 'wb') as output:
pickle.dump(statistics, output, pickle.HIGHEST_PROTOCOL)
def collect_samples_multithread(self):
#queue = Queue.Queue()
self.lr = 1e-4
self.weight = 10
num_threads = 10
seeds = [
np.random.randint(0, 4294967296) for _ in range(num_threads)
]
ts = [
mp.Process(target=self.collect_samples,args=(300,), kwargs={'noise':-2.0, 'random_seed':seed})
for seed in seeds
]
for t in ts:
t.start()
#print("started")
self.model.set_noise(-2.0)
while True:
self.save_model("torch_model/corl_demo.pt")
import time; start = time.time()
while len(self.memory.memory) < 3000:
#print(len(self.memory.memory))
if self.counter.get() == num_threads:
for i in range(num_threads):
self.memory.push(self.queue.get())
self.counter.increment()
if len(self.memory.memory) < 3000 and self.counter.get() == num_threads + 1:
self.counter.reset()
self.traffic_light.switch()
self.update_critic(512, self.critic_update_rate)
self.update_actor(512, self.actor_update_rate, supervised=self.supervised)
self.clear_memory()
print("time spent on current iteration", time.time() - start)
self.run_test(num_test=2)
self.run_test_with_noise(num_test=2)
#self.validation()
self.plot_statistics()
self.traffic_light.switch()
self.counter.reset()
def add_env(self, env):
self.env_list.append(env)
def mkdir(base, name):
path = os.path.join(base, name)
if not os.path.exists(path):
os.makedirs(path)
return path
def train_policy_rl():
torch.set_num_threads(1)
env = cassieRLEnvMirrorIKTraj()
env.delay = False
env.noisy = False
ppo = RL(env, [256, 256])
RL.supervised = False
RL.policy_weight = 1
RL.actor_update_rate = 16
RL.critic_update_rate = 16
with open('torch_model/cassie3dMirror2kHz_shared_obs_stats.pkl', 'rb') as input:
ppo.shared_obs_stats = pickle.load(input)
ppo.collect_samples_multithread()
start = t.time()
noise = -2.0
def train_policy_rl_sl():
torch.set_num_threads(1)
env = cassieRLEnvMirror()
env.delay = False
env.noisy = False
ppo = RL(env, [256, 256])
RL.supervised = True
RL.policy_weight = 0
RL.actor_update_rate = 6400
RL.critic_update_rate = 0
for speed in range(0 ,1):
ppo.collect_expert_samples(300, "torch_model/StablePelvisForwardBackward256X256Jan25.pt", speed=speed/10.0, y_speed=0)
#for speed in range(-5, 0):
#ppo.collect_expert_samples(300, "torch_model/StablePelvisForwardBackward256X256Jan25.pt", speed=speed/10.0, y_speed=0)
#for speed in range(0 ,11):
#ppo.collect_expert_samples(300, "torch_model/StablePelvisForwardBackward256X256Jan25.pt", speed=speed/10.0, y_speed=0)
with open('torch_model/cassie3dMirror2kHz_shared_obs_stats.pkl', 'rb') as input:
ppo.shared_obs_stats = pickle.load(input)
ppo.collect_samples_multithread()
start = t.time()
noise = -2.0
if __name__ == '__main__':
train_policy_rl()