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

Method __init__

diff2flow/ddpm.py:92–127  ·  view source on GitHub ↗
(self,
                 timesteps=1000,
                 beta_schedule="linear",
                 zero_terminal_snr=False,
                 loss_type="l2",
                 parameterization="eps",  # all assuming fixed variance schedules
                 linear_start=1e-4,
                 linear_end=2e-2,
                 cosine_s=8e-3,
                 original_elbo_weight=0.,
                 v_posterior=0.,  # weight for choosing posterior variance as sigma = (1-v) * beta_tilde + v * beta
                 l_simple_weight=1.,
                 )

Source from the content-addressed store, hash-verified

90
91class GaussianDiffusion(nn.Module):
92 def __init__(self,
93 timesteps=1000,
94 beta_schedule="linear",
95 zero_terminal_snr=False,
96 loss_type="l2",
97 parameterization="eps", # all assuming fixed variance schedules
98 linear_start=1e-4,
99 linear_end=2e-2,
100 cosine_s=8e-3,
101 original_elbo_weight=0.,
102 v_posterior=0., # weight for choosing posterior variance as sigma = (1-v) * beta_tilde + v * beta
103 l_simple_weight=1.,
104 ):
105 super().__init__()
106 self.parameterization = parameterization
107 self.loss_type = loss_type
108 print(f"[{self.__class__.__name__}]: Running in {self.parameterization}-prediction mode")
109
110 self.v_posterior = v_posterior
111 self.original_elbo_weight = original_elbo_weight
112 self.l_simple_weight = l_simple_weight
113
114 if zero_terminal_snr:
115 assert beta_schedule == "linear", "enforce_zero_terminal_snr only works with linear beta schedules"
116 assert parameterization == "v", "enforce_zero_terminal_snr only works with v-parameterization"
117
118 self.register_schedule(
119 beta_schedule=beta_schedule,
120 timesteps=timesteps,
121 linear_start=linear_start,
122 linear_end=linear_end,
123 cosine_s=cosine_s,
124 zero_terminal_snr=zero_terminal_snr
125 )
126
127 self.loss_type = loss_type
128
129 def register_schedule(self, beta_schedule="linear", timesteps=1000,
130 linear_start=1e-4, linear_end=2e-2, cosine_s=8e-3,

Callers

nothing calls this directly

Calls 1

register_scheduleMethod · 0.95

Tested by

no test coverage detected