MCPcopy
hub / github.com/hojonathanho/diffusion / q_sample

Method q_sample

diffusion_tf/diffusion_utils_2.py:101–111  ·  view source on GitHub ↗

Diffuse the data (t == 0 means diffused for 1 step)

(self, x_start, t, noise=None)

Source from the content-addressed store, hash-verified

99 return mean, variance, log_variance
100
101 def q_sample(self, x_start, t, noise=None):
102 """
103 Diffuse the data (t == 0 means diffused for 1 step)
104 """
105 if noise is None:
106 noise = tf.random_normal(shape=x_start.shape)
107 assert noise.shape == x_start.shape
108 return (
109 self._extract(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start +
110 self._extract(self.sqrt_one_minus_alphas_cumprod, t, x_start.shape) * noise
111 )
112
113 def q_posterior_mean_variance(self, x_start, x_t, t):
114 """

Callers 2

training_lossesMethod · 0.95
_loop_bodyMethod · 0.95

Calls 1

_extractMethod · 0.95

Tested by

no test coverage detected