MCPcopy Index your code
hub / github.com/CompVis/diff2flow / get_score_from_velocity

Method get_score_from_velocity

diff2flow/flow.py:119–133  ·  view source on GitHub ↗

Wrapper function: transfrom velocity prediction model to score 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

117 return diffusion
118
119 def get_score_from_velocity(self, velocity, x, t):
120 """Wrapper function: transfrom velocity prediction model to score
121 Args:
122 velocity: [batch_dim, ...] shaped tensor; velocity model output
123 x: [batch_dim, ...] shaped tensor; x_t data point
124 t: [batch_dim,] time tensor
125 """
126 t = pad_v_like_x(t, x)
127 alpha_t, d_alpha_t = self.compute_alpha_t(t)
128 sigma_t, d_sigma_t = self.compute_sigma_t(t)
129 mean = x
130 reverse_alpha_ratio = alpha_t / d_alpha_t
131 var = sigma_t**2 - reverse_alpha_ratio * d_sigma_t * sigma_t
132 score = (reverse_alpha_ratio * velocity - mean) / var
133 return score
134
135 def get_noise_from_velocity(self, velocity, x, t):
136 """Wrapper function: transfrom velocity prediction model to denoiser

Callers 1

scoreMethod · 0.80

Calls 3

compute_alpha_tMethod · 0.95
compute_sigma_tMethod · 0.95
pad_v_like_xFunction · 0.85

Tested by

no test coverage detected