-
Notifications
You must be signed in to change notification settings - Fork 11
/
vis.py
28 lines (25 loc) · 795 Bytes
/
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
import numpy as np
from scipy.misc import imsave
def grayscale_grid_vis(X, (nh, nw), save_path=None):
h, w = X[0].shape[:2]
img = np.zeros((h*nh, w*nw))
for n, x in enumerate(X):
j = n/nw
i = n%nw
img[j*h:j*h+h, i*w:i*w+w] = x
if save_path is not None:
imsave(save_path, img)
return img
def color_grid_vis(X, (nh, nw), save_path=None):
h, w = X[0].shape[:2]
img = np.zeros((h*nh, w*nw, 3))
for n, x in enumerate(X):
j = n/nw
i = n%nw
img[j*h:j*h+h, i*w:i*w+w, :] = x
if save_path is not None:
imsave(save_path, img)
return img
def grayscale_weight_grid_vis(w, (nh, nw), save_path=None):
w = (w+w.min())/(w.max()-w.min())
return grayscale_grid_vis(w, (nh, nw), save_path=save_path)