本文整理匯總了Python中lib.save_params方法的典型用法代碼示例。如果您正苦於以下問題:Python lib.save_params方法的具體用法?Python lib.save_params怎麽用?Python lib.save_params使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lib
的用法示例。
在下文中一共展示了lib.save_params方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_and_save_samples
# 需要導入模塊: import lib [as 別名]
# 或者: from lib import save_params [as 別名]
def generate_and_save_samples(tag):
lib.save_params(os.path.join(OUT_DIR, tag + "_params.pkl"))
def save_images(images, filename, i = None):
"""images.shape: (batch, n channels, height, width)"""
if i is not None:
new_tag = "{}_{}".format(tag, i)
else:
new_tag = tag
images = images.reshape((10,10,28,28))
images = images.transpose(1,2,0,3)
images = images.reshape((10*28, 10*28))
image = scipy.misc.toimage(images, cmin=0.0, cmax=1.0)
image.save('{}/{}_{}.jpg'.format(OUT_DIR, filename, new_tag))
latents = np.random.normal(size=(100, LATENT_DIM))
latents = latents.astype(theano.config.floatX)
samples = np.zeros(
(100, N_CHANNELS, HEIGHT, WIDTH),
dtype=theano.config.floatX
)
next_sample = samples.copy()
t0 = time.time()
for j in xrange(HEIGHT):
for k in xrange(WIDTH):
for i in xrange(N_CHANNELS):
samples_p_value = sample_fn(latents, next_sample)
next_sample[:, i, j, k] = binarize(samples_p_value)[:, i, j, k]
samples[:, i, j, k] = samples_p_value[:, i, j, k]
t1 = time.time()
print("Time taken for generation {:.4f}".format(t1 - t0))
save_images(samples_p_value, 'samples')