-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
22 lines (21 loc) · 825 Bytes
/
util.py
File metadata and controls
22 lines (21 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import matplotlib.pyplot as plt
import numpy as np
def plot_grid(images, grid_size=(8,8), imsize=(28,28), file=None):
fig = plt.figure(figsize=(10,10))
imagerow = images[0].reshape(*imsize)
for i in range(1,grid_size[0]):
imagerow = np.hstack([imagerow, images[i].reshape(*imsize)])
image = imagerow.copy()
for j in range(1,grid_size[1]):
imagerow = images[(grid_size[0]*j)].reshape(*imsize)
for i in range(1, grid_size[0]):
imagerow = np.hstack([imagerow,
images[(grid_size[0]*j)+i].reshape(*imsize)])
image = np.vstack([image, imagerow])
plt.imshow(image, cmap = 'gray')
plt.xticks([])
plt.yticks([])
if file is not None:
plt.imsave(file,image, cmap='gray',dpi=200)
else:
plt.show()