-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_hopper.py
More file actions
62 lines (50 loc) · 3.44 KB
/
plot_hopper.py
File metadata and controls
62 lines (50 loc) · 3.44 KB
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
import numpy as np
import matplotlib.pyplot as plt
RUNS = 10 # Number of statistical runs
steps = np.load('results/Hopper_v4_TD3/run_0/evaluations.npz')['timesteps']
#breakpoint()
returns_TD3_v4 = np.average(np.array([np.load('results/Hopper_v4_TD3/run_' + str(run) + '/evaluations.npz')['results'] for run in range(0, RUNS)]), axis=2)
returns_TD3_v5 = np.average(np.array([np.load('results/Hopper_v5_TD3/run_' + str(run) + '/evaluations.npz')['results'] for run in range(0, RUNS)]), axis=2)
returns_PPO_v4 = np.average(np.array([np.load('results/Hopper_v4_PPO/run_' + str(run) + '/evaluations.npz')['results'] for run in range(0, RUNS)]), axis=2)
returns_PPO_v5 = np.average(np.array([np.load('results/Hopper_v5_PPO/run_' + str(run) + '/evaluations.npz')['results'] for run in range(0, RUNS)]), axis=2)
returns_TD3_v4_len = np.average(np.array([np.load('results/Hopper_v4_TD3/run_' + str(run) + '/evaluations.npz')['ep_lengths'] for run in range(0, RUNS)]), axis=2)
returns_TD3_v5_len = np.average(np.array([np.load('results/Hopper_v5_TD3/run_' + str(run) + '/evaluations.npz')['ep_lengths'] for run in range(0, RUNS)]), axis=2)
returns_PPO_v4_len = np.average(np.array([np.load('results/Hopper_v4_PPO/run_' + str(run) + '/evaluations.npz')['ep_lengths'] for run in range(0, RUNS)]), axis=2)
returns_PPO_v5_len = np.average(np.array([np.load('results/Hopper_v5_PPO/run_' + str(run) + '/evaluations.npz')['ep_lengths'] for run in range(0, RUNS)]), axis=2)
#breakpoint()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(steps, np.average(returns_TD3_v4, axis=0), label='v4 TD3')
ax.plot(steps, np.average(returns_TD3_v5, axis=0), label='v5 TD3')
ax.plot(steps, np.average(returns_PPO_v4, axis=0), label='v4 PPO')
ax.plot(steps, np.average(returns_PPO_v5, axis=0), label='v5 PPO')
ax.fill_between(steps, np.min(returns_TD3_v4, axis=0), np.max(returns_TD3_v4, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_TD3_v5, axis=0), np.max(returns_TD3_v5, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_PPO_v4, axis=0), np.max(returns_PPO_v4, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_PPO_v5, axis=0), np.max(returns_PPO_v5, axis=0), alpha=0.2)
ax.set_title('SB3 on MuJoCo/Hopper, for ' + str(RUNS) + ' Runs, episodic returns')
ax.legend()
fig.set_figwidth(16)
fig.set_figheight(9)
file_name = "figures/Hopper"
plt.savefig(file_name + ".eps", bbox_inches="tight")
plt.savefig(file_name + ".png", bbox_inches="tight")
#fig.show()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(steps, np.average(returns_TD3_v4_len, axis=0), label='v4 TD3')
ax.plot(steps, np.average(returns_TD3_v5_len, axis=0), label='v5 TD3')
ax.plot(steps, np.average(returns_PPO_v4_len, axis=0), label='v4 PPO')
ax.plot(steps, np.average(returns_PPO_v5_len, axis=0), label='v5 PPO')
ax.fill_between(steps, np.min(returns_TD3_v4_len, axis=0), np.max(returns_TD3_v4_len, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_TD3_v5_len, axis=0), np.max(returns_TD3_v5_len, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_PPO_v4_len, axis=0), np.max(returns_PPO_v4_len, axis=0), alpha=0.2)
ax.fill_between(steps, np.min(returns_PPO_v5_len, axis=0), np.max(returns_PPO_v5_len, axis=0), alpha=0.2)
ax.set_title('SB3 on MuJoCo/Hopper, for ' + str(RUNS) + ' Runs, episodic lenghts')
ax.legend()
fig.set_figwidth(16)
fig.set_figheight(9)
file_name = "figures/Hopper_len"
plt.savefig(file_name + ".eps", bbox_inches="tight")
plt.savefig(file_name + ".png", bbox_inches="tight")
#breakpoint()