from tqdm import tqdm import torch from testing.Sampler import Sampler class EulerHeunSampler(Sampler): def __init__(self, model, diff_params, args): super().__init__(model, diff_params, args) #stochasticity parameters self.Schurn=self.args.tester.sampling_params.Schurn self.Snoise=self.args.tester.sampling_params.Snoise self.Stmin=self.args.tester.sampling_params.Stmin self.Stmax=self.args.tester.sampling_params.Stmax #order of the sampler self.order=self.args.tester.sampling_params.order def initialize_x(self, shape, device, schedule): x = schedule[0]*torch.randn(shape).to(device) return x def get_gamma(self, t): """ Get the parameter gamma that defines the stochasticity of the sampler Args t (Tensor): shape: (N_steps, ) Tensor of timesteps, from which we will compute gamma """ N=t.shape[0] gamma=torch.zeros(t.shape).to(t.device) #If desired, only apply stochasticity between a certain range of noises Stmin is 0 by default and Stmax is a huge number by default. (Unless these parameters are specified, this does nothing) indexes=torch.logical_and(t>self.Stmin , t