-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_loss.py
65 lines (51 loc) · 2.25 KB
/
plot_loss.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
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('ggplot')
def plot_loss():
loss_one_step = np.genfromtxt('./loss/lstm_auto_encoder/loss_128h_3step_nonlinear_5k_epochs.csv', delimiter=',')
loss_two_step = np.genfromtxt('./loss/lstm_auto_encoder/loss_128h_3step_nonlinear_5k_epochs.csv', delimiter=',')
fig, axes = plt.subplots(2, 1)
# fig.suptitle('[2 Step Prediction - Training: 5k - Validation: 1k]')
fig.set_size_inches(12, 8)
axes[0].set_title('128h')
# axes[0].set_xlabel('Number of Epochs')
# axes[0].set_ylabel('Loss ||$f(s_t, a_t) - s_{t+1}||$')
axes[0].set_ylabel('Loss')
axes[0].legend(('training', 'validation'))
axes[0].plot(loss_one_step[100:, 0], linewidth=3)
axes[0].plot(loss_one_step[100:, 1], '--', linewidth=3)
axes[1].set_title('256h')
axes[1].set_xlabel('Number of Epochs')
# axes[0].set_ylabel('Loss ||$f(s_t, a_t) - s_{t+1}||$')
axes[1].set_ylabel('Loss')
axes[1].legend(('training', 'validation'))
axes[1].plot(loss_two_step[100:, 0], linewidth=3)
axes[1].plot(loss_two_step[100:, 1], '--', linewidth=3)
# fig.tight_layout()
plt.show()
def plot_temporal_vae():
loss = np.genfromtxt('./loss/temporal_vae/16h_4l_0.01beta.csv', delimiter=',')
fig, axes = plt.subplots(2, 1)
# fig.suptitle('beta = 0.0001')
fig.set_size_inches(12, 8)
beta_str = str(0.01)
axes[0].set_title('Training Set - beta: ' + beta_str)
axes[0].set_ylabel('Loss')
axes[0].plot(loss[:, 0], label='total', linewidth=2)
axes[0].plot(loss[:, 1], label='reconstruction', linewidth=2)
axes[0].plot(loss[:, 2], label='prediction', linewidth=2)
axes[0].plot(loss[:, 3], label='kl divergence', linewidth=2)
axes[1].set_title('Validation Set - beta: ' + beta_str)
axes[1].set_xlabel('Number of Epochs')
axes[1].set_ylabel('Loss')
axes[1].legend(('training', 'validation'))
axes[1].plot(loss[:, 4], label='total', linewidth=2)
axes[1].plot(loss[:, 5], label='reconstruction', linewidth=2)
axes[1].plot(loss[:, 6], label='prediction', linewidth=2)
axes[1].plot(loss[:, 7], label='kl divergence', linewidth=2)
plt.legend()
plt.tight_layout()
plt.show()
if __name__ == '__main__':
# plot_loss()
plot_temporal_vae()