MCPcopy Create free account
hub / github.com/Extraltodeus/DistanceSampler / simplified_euler

Function simplified_euler

custom_samplers.py:249–261  ·  view source on GitHub ↗
(model, x, sigmas, extra_args=None, callback=None, disable=None)

Source from the content-addressed store, hash-verified

247# as a reference
248@torch.no_grad()
249def simplified_euler(model, x, sigmas, extra_args=None, callback=None, disable=None):
250 extra_args = {} if extra_args is None else extra_args
251 s_in = x.new_ones([x.shape[0]])
252 for i in trange(len(sigmas) - 1, disable=disable):
253 sigma_hat = sigmas[i]
254 denoised = model(x, sigma_hat * s_in, **extra_args)
255 d = to_d(x, sigma_hat, denoised)
256 if callback is not None:
257 callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised})
258 dt = sigmas[i + 1] - sigma_hat
259 # Euler method
260 x = x + d * dt
261 return x
262
263class SamplerDistanceBase:
264 _DISTANCE_OPTIONS = None # All options by default.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected