forked from KalraA/real-nvp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
33 lines (28 loc) · 1.01 KB
/
util.py
File metadata and controls
33 lines (28 loc) · 1.01 KB
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
import tensorflow as tf
import numpy as np
import time
import matplotlib.pyplot as plt
from pylab import rcParams
def show_all_variables():
total_count = 0
for idx, op in enumerate(tf.trainable_variables()):
shape = op.get_shape()
count = np.prod(shape)
print ("[%2d] %s %s = %s" % (idx, op.name, shape, count))
total_count += int(count)
print ("[Total] variable size: %s" % "{:,}".format(total_count))
def save_images_with_nll(images, nlls):
num_images = images.shape[0]
num_images_per_row = 4
num_images_per_column = (num_images + num_images_per_row - 1) // num_images_per_row
idx = 0
for i in range(num_images_per_column):
for j in range(num_images_per_row):
plt.subplot2grid((num_images_per_column,num_images_per_row),(i, j))
plt.axis('off')
plt.imshow(images[idx])
plt.title('%f' % nlls[idx])
idx += 1
if idx >= num_images:
plt.savefig('test_results/samples_%s.png' % time.strftime("%m_%d_%H_%M_%S"), bbox_inches='tight')
return