MCPcopy Create free account
hub / github.com/CompVis/diff2flow / get_noise_from_velocity

Method get_noise_from_velocity

diff2flow/flow.py:135–149  ·  view source on GitHub ↗

Wrapper function: transfrom velocity prediction model to denoiser Args: velocity: [batch_dim, ...] shaped tensor; velocity model output x: [batch_dim, ...] shaped tensor; x_t data point t: [batch_dim,] time tensor

(self, velocity, x, t)

Source from the content-addressed store, hash-verified

133 return score
134
135 def get_noise_from_velocity(self, velocity, x, t):
136 """Wrapper function: transfrom velocity prediction model to denoiser
137 Args:
138 velocity: [batch_dim, ...] shaped tensor; velocity model output
139 x: [batch_dim, ...] shaped tensor; x_t data point
140 t: [batch_dim,] time tensor
141 """
142 t = pad_v_like_x(t, x)
143 alpha_t, d_alpha_t = self.compute_alpha_t(t)
144 sigma_t, d_sigma_t = self.compute_sigma_t(t)
145 mean = x
146 reverse_alpha_ratio = alpha_t / d_alpha_t
147 var = reverse_alpha_ratio * d_sigma_t - sigma_t
148 noise = (reverse_alpha_ratio * velocity - mean) / var
149 return noise
150
151 def get_velocity_from_score(self, score, x, t):
152 """Wrapper function: transfrom score prediction model to velocity

Callers

nothing calls this directly

Calls 3

compute_alpha_tMethod · 0.95
compute_sigma_tMethod · 0.95
pad_v_like_xFunction · 0.85

Tested by

no test coverage detected