89 [[nodiscard]]
float beta(int64_t t)
const;
96 [[nodiscard]]
float alpha(int64_t t)
const;
171 int64_t s,
float eta = 0.0f)
const;
182 [[nodiscard]]
size_t index_of(int64_t t,
const char* context)
const;
184 int64_t num_timesteps_;
185 std::vector<float> beta_;
186 std::vector<float> alpha_;
187 std::vector<float> alpha_bar_;
The DDPM (Ho et al. 2020, arXiv:2006.11239) linear variance schedule plus the two tensor operations d...
Definition noise_schedule.hpp:54
float alpha_bar(int64_t t) const
alpha_bar_t = prod_{s=1..t} alpha_s (the cumulative product).
Tensor ddim_step(const Tensor &x_t, const Tensor &predicted_epsilon, const Tensor &z, int64_t t, int64_t s, float eta=0.0f) const
Applies ddim_coefficients(t, s, eta): skip * x_t - network * eps + noise * z.
static NoiseSchedule Cosine(int64_t num_timesteps, double offset=0.008, double max_beta=0.999)
The cosine schedule of Nichol & Dhariwal 2021 (arXiv:2102.09672): alpha_bar_t = f(t) / f(0) with f(t)...
NoiseSchedule(int64_t num_timesteps, float beta_start=1e-4f, float beta_end=0.02f)
Precomputes the linear beta schedule and its alpha / alpha_bar derivatives.
Tensor add_noise(const Tensor &x0, const Tensor &epsilon, int64_t t) const
Closed-form forward (noising) sample: x_t = sqrt(alpha_bar_t) * x0 + sqrt(1 - alpha_bar_t) * epsilon.
Tensor denoise_step(const Tensor &x_t, const Tensor &predicted_epsilon, const Tensor &z, int64_t t) const
One reverse (sampling) step, x_{t-1} = mean_term + sqrt(beta_t) * z where the mean term is (1/sqrt(al...
float beta(int64_t t) const
Variance beta_t at timestep t.
float alpha(int64_t t) const
alpha_t = 1 - beta_t.
ReverseStepCoefficients ddim_coefficients(int64_t t, int64_t s, float eta=0.0f) const
A DDIM step (Song et al. 2021, arXiv:2010.02502, eq. 12) from t to an earlier s: x_s = sqrt(alpha_bar...
ReverseStepCoefficients ddpm_coefficients(int64_t t) const
denoise_step()'s coefficients: skip 1/sqrt(alpha_t), network beta_t / (sqrt(alpha_t) sqrt(1 - alpha_b...
int64_t num_timesteps() const
Number of diffusion steps T this schedule was built for.
Definition noise_schedule.hpp:82
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
Definition acquisition_functions.hpp:16
One reverse step as x_prev = skip * x_t - network * eps_theta + noise * z (DIFF-5)....
Definition noise_schedule.hpp:20
float network
Definition noise_schedule.hpp:22
float skip
Definition noise_schedule.hpp:21
float noise
Definition noise_schedule.hpp:23
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).