def sample_scan(self, x, sigma, n_steps, samples):
# Enable on-the-fly graph computations
# theano.config.compute_test_value = "raise"
in_val = T.fmatrix("input_values")
# in_val.tag.test_value = np.asarray(
# np.random.rand(1, 784), dtype=theano.config.floatX)
s_sigma = T.fscalr("sigma_values")
# s_sigma = np.asarray(
# np.random.rand(1), dtype=theano.config.floatX)
mode = "FAST_RUN"
values, updates = theano.scan(fn=self.sample_one_step,
outputs_info=in_val,
non_sequences=s_sigma,
n_steps=n_steps,
mode=mode)
ae_sampler = theano.function(inputs=[in_val, s_sigma],
outputs=values[-1],
updates=updates)
samples = ae_sampler(x, sigma)
return samples
评论列表
文章目录