This repository has been archived by the owner on Jul 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vis.py
106 lines (82 loc) · 2.94 KB
/
vis.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
import json
import matplotlib.pyplot as plt
fontsize = 15
def plot_dqn_visualization():
with open("models/dqn_training_status.json") as f:
data = json.load(f)
episode_length = data["episode_length"]
reward = data["reward"]
losses = data["losses"]
plt.figure()
plt.plot(episode_length)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Length Of Episode", fontsize=fontsize)
plt.savefig("episode_length_dqn.jpg")
plt.figure()
plt.plot(reward)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Total Reward", fontsize=fontsize)
plt.savefig("reward_dqn.jpg")
plt.figure()
plt.plot(losses)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Losses", fontsize=fontsize)
plt.savefig("losses_dqn.jpg")
def plot_ddqn_visualization():
with open("models/ddqn_training_status.json") as f:
data = json.load(f)
episode_length = data["episode_length"]
reward = data["reward"]
losses = data["losses"]
plt.figure()
plt.plot(episode_length)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Length Of Episode", fontsize=fontsize)
plt.savefig("episode_length_ddqn.jpg")
plt.figure()
plt.plot(reward)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Total Reward", fontsize=fontsize)
plt.savefig("reward_ddqn.jpg")
plt.figure()
plt.plot(losses)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Losses", fontsize=fontsize)
plt.savefig("losses_ddqn.jpg")
def plot_a2c_visualization():
with open("models/a2c_training_status.json") as f:
data = json.load(f)
episode_length = data["episode_len_list"]
reward = data["reward_list"]
policy_losses = data["policy_losses_list"]
value_losses = data["value_losses_list"]
entropy_losses = data["entropy_losses_list"]
plt.figure()
plt.plot(episode_length)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Length Of Episode", fontsize=fontsize)
plt.savefig("episode_length_a2c.jpg")
plt.figure()
plt.plot(reward)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Total Reward", fontsize=fontsize)
plt.savefig("reward_a2c.jpg")
plt.figure()
plt.plot(policy_losses)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Policy Losses", fontsize=fontsize)
plt.savefig("policy_losses_a2c.jpg")
plt.figure()
plt.plot(value_losses)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Value Losses", fontsize=fontsize)
plt.savefig("value_losses_a2c.jpg")
plt.figure()
plt.plot(entropy_losses)
plt.xlabel("Number Of Episodes", fontsize=fontsize)
plt.ylabel("Entropy Losses", fontsize=fontsize)
plt.savefig("entropy_losses_a2c.jpg")
if __name__ == "__main__":
plot_dqn_visualization()
plot_ddqn_visualization()
plot_a2c_visualization()