-
Notifications
You must be signed in to change notification settings - Fork 4
/
Utils.py
33 lines (27 loc) · 859 Bytes
/
Utils.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
import matplotlib.pyplot as plt
import numpy as np
import torch.nn as nn
def Plot_loss_curve(train_list, test_dict):
x_tst = list(test_dict.keys())
y_tst = list(test_dict.values())
train_x_vals = np.arange(len(train_list))
plt.figure(2)
plt.xlabel('Num Steps')
plt.ylabel('ELBO')
plt.title('ELBO Loss Curve')
plt.plot(train_x_vals, train_list, label='train')
plt.plot(x_tst, y_tst, label='tst')
plt.legend(loc='best')
plt.locator_params(axis='x', nbins=10)
plt.show()
return
def create_canvas(x):
rows = 10
columns = 10
plt.figure(1)
canvas = np.zeros((28 * rows, columns * 28))
for i in range(rows):
for j in range(columns):
idx = i % columns + rows * j
canvas[i * 28:(i + 1) * 28, j * 28:(j + 1) * 28] = x[idx].reshape((28, 28))
return canvas