MCPcopy Create free account
hub / github.com/LTH14/mar / p_sample_loop

Method p_sample_loop

diffusion/gaussian_diffusion.py:422–468  ·  view source on GitHub ↗

Generate samples from the model. :param model: the model module. :param shape: the shape of the samples, (N, C, H, W). :param noise: if specified, the noise from the encoder to sample. Should be of the same shape as `shape`. :param clip_

(
        self,
        model,
        shape,
        noise=None,
        clip_denoised=True,
        denoised_fn=None,
        cond_fn=None,
        model_kwargs=None,
        device=None,
        progress=False,
        temperature=1.0,
    )

Source from the content-addressed store, hash-verified

420 return {"sample": sample, "pred_xstart": out["pred_xstart"]}
421
422 def p_sample_loop(
423 self,
424 model,
425 shape,
426 noise=None,
427 clip_denoised=True,
428 denoised_fn=None,
429 cond_fn=None,
430 model_kwargs=None,
431 device=None,
432 progress=False,
433 temperature=1.0,
434 ):
435 """
436 Generate samples from the model.
437 :param model: the model module.
438 :param shape: the shape of the samples, (N, C, H, W).
439 :param noise: if specified, the noise from the encoder to sample.
440 Should be of the same shape as `shape`.
441 :param clip_denoised: if True, clip x_start predictions to [-1, 1].
442 :param denoised_fn: if not None, a function which applies to the
443 x_start prediction before it is used to sample.
444 :param cond_fn: if not None, this is a gradient function that acts
445 similarly to the model.
446 :param model_kwargs: if not None, a dict of extra keyword arguments to
447 pass to the model. This can be used for conditioning.
448 :param device: if specified, the device to create the samples on.
449 If not specified, use a model parameter's device.
450 :param progress: if True, show a tqdm progress bar.
451 :param temperature: temperature scaling during Diff Loss sampling.
452 :return: a non-differentiable batch of samples.
453 """
454 final = None
455 for sample in self.p_sample_loop_progressive(
456 model,
457 shape,
458 noise=noise,
459 clip_denoised=clip_denoised,
460 denoised_fn=denoised_fn,
461 cond_fn=cond_fn,
462 model_kwargs=model_kwargs,
463 device=device,
464 progress=progress,
465 temperature=temperature,
466 ):
467 final = sample
468 return final["sample"]
469
470 def p_sample_loop_progressive(
471 self,

Callers 1

sampleMethod · 0.80

Calls 1

Tested by

no test coverage detected