Title: On Calibrating Diffusion Probabilistic Models
Venue: NeurIPS 2023
Accepted: yes
Keywords: Diffusion Probabilistic Models

Model Calibration
Abstract: Recently, diffusion probabilistic models (DPMs) have achieved promising results in diverse generative tasks. A typical DPM framework includes a forward process that gradually diffuses the data distribution and a reverse process that recovers the data distribution from time-dependent data scores. In this work, we observe that the stochastic reverse process of data scores is a martingale, from which concentration bounds and the optional stopping theorem for data scores can be derived. Then, we discover a simple way for calibrating an arbitrary pretrained DPM, with which the score matching loss can be reduced and the lower bounds of model likelihood can consequently be increased. We provide general calibration guidelines under various model parametrizations. Our calibration method is performed only once and the resulting models can be used repeatedly for sampling. We conduct experiments on multiple datasets to empirically validate our proposal. Our code is available at https://github.com/thudzj/Calibrated-DPMs.

On Calibrating Diffusion Probabilistic Models

Abstract

Recently, diffusion probabilistic models (DPMs) have achieved promising results in diverse generative tasks. A typical DPM framework includes a forward process that gradually diffuses the data distribution and a reverse process that recovers the data distribution from time-dependent data scores. In this work, we observe that the stochastic reverse process of data scores is a martingale, from which concentration bounds and the optional stopping theorem for data scores can be derived. Then, we discover a simple way for calibrating an arbitrary pretrained DPM, with which the score matching loss can be reduced and the lower bounds of model likelihood can consequently be increased. We provide general calibration guidelines under various model parametrizations. Our calibration method is performed only once and the resulting models can be used repeatedly for sampling. We conduct experiments on multiple datasets to empirically validate our proposal. Our code is available at https://github.com/thudzj/Calibrated-DPMs.

1 Introduction

In the past few years, denoising diffusion probabilistic modeling [17, 40] and score-based Langevin dynamics [42, 43] have demonstrated appealing results on generating images. Later, Song et al. [46] unify these two generative learning mechanisms through stochastic/ordinary differential equations (SDEs/ODEs). In the following we refer to this unified model family as diffusion probabilistic models (DPMs). The emerging success of DPMs has attracted broad interest in downstream applications, including image generation [10, 22, 48], shape generation [4], video generation [18, 19], superresolution [35], speech synthesis [5], graph generation [51], textual inversion [13, 34], improving adversarial robustness [50], and text-to-image large models [32, 33], just to name a few.

A typical framework of DPMs involves a forward process gradually diffusing the data distribution q 0 ( x 0 ) towards a noise distribution q T ( x T ) . The transition probability for t ∈ [0 , T ] is a conditional Gaussian distribution q 0 t ( x t | x 0 ) = N ( x t | α t x 0 , σ 2 t I ) , where α t , σ t ∈ R + . Song et al. [46] show that there exist reverse SDE/ODE processes starting from q T ( x T ) and sharing the same marginal distributions q t ( x t ) as the forward process. The only unknown term in the reverse processes is the data score ∇ x t log q t ( x t ) , which can be approximated by a time-dependent score model s t θ ( x t ) (or with other model parametrizations). s t θ ( x t ) is typically learned via score matching (SM) [20].

In this work, we observe that the stochastic process of the scaled data score α t ∇ x t log q t ( x t ) is a martingale w.r.t. the reverse-time process of x t from T to 0 , where the timestep t can be either continuous or discrete. Along the reverse-time sampling path, this martingale property leads to concentration bounds for scaled data scores. Moreover, a martingale satisfies the optional stopping theorem that the expected value at a stopping time is equal to its initial expected value.

Based on the martingale property of data scores, for any t ∈ [0 , T ] and any pretrained score model s t θ ( x t ) (or with other model parametrizations), we can calibrate the model by subtracting its expectation over q t ( x t ) , i.e., E q t ( x t ) [ s t θ ( x t )] . We formally demonstrate that the calibrated score model s t θ ( x t ) -E q t ( x t ) [ s t θ ( x t )] achieves lower values of SM objectives. By the connections between SM objectives and model likelihood of the SDE process [23, 45] or the ODE process [28], the calibrated score model has higher evidence lower bounds. Similar conclusions also hold for the conditional case, in which we calibrate a conditional score model s t θ ( x t , y ) by subtracting its conditional expectation E q t ( x t | y ) [ s t θ ( x t , y )] .

In practice, E q t ( x t ) [ s t θ ( x t )] or E q t ( x t | y ) [ s t θ ( x t , y )] can be approximated using noisy training data when the score model has been pretrained. We can also utilize an auxiliary shallow model to estimate these expectations dynamically during pretraining. When we do not have access to training data, we could calculate the expectations using data generated from s t θ ( x t ) or s t θ ( x t , y ) . In experiments, we evaluate our calibration tricks on the CIFAR-10 [25] and CelebA 64 × 64 [27] datasets, reporting the FID scores [16]. We also provide insightful visualization results on the AFHQv2 [7], FFHQ [21] and ImageNet [9] at 64 × 64 resolution.

2 Diffusion probabilistic models

In this section, we briefly review the notations and training paradigms used in diffusion probabilistic models (DPMs). While recent works develop DPMs based on general corruptions [2, 8], we mainly focus on conventional Gaussian-based DPMs.

2.1 Forward and reverse processes

We consider a k -dimensional random variable x ∈ R k and define a forward diffusion process on x as { x t } t ∈ [0 ,T ] with T > 0 , which satisfies ∀ t ∈ [0 , T ] ,

Here q 0 ( x 0 ) is the data distribution; α t and σ t are two positive real-valued functions that are differentiable w.r.t. t with bounded derivatives. Let q t ( x t ) = ∫ q 0 t ( x t | x 0 ) q 0 ( x 0 ) dx 0 be the marginal distribution of x t . The schedules of α t , σ 2 t need to ensure that q T ( x T ) ≈ N ( x T | 0 , ˜ σ 2 I ) for some ˜ σ . Kingma et al. [23] prove that there exists a stochastic differential equation (SDE) satisfying the forward transition distribution in Eq. (1), and this SDE can be written as dx t = f ( t ) x t dt + g ( t ) dω t , (2)

where ω t ∈ R k is the standard Wiener process, f ( t ) = d log α t dt , and g ( t ) 2 = dσ 2 t dt -2 d log α t dt σ 2 t . Song et al. [46] demonstrate that the forward SDE in Eq. (2) corresponds to a reverse SDE constructed as where ω t ∈ R k is the standard Wiener process in reverse time. Starting from q T ( x T ) , the marginal distribution of the reverse SDE process is also q t ( x t ) for t ∈ [0 , T ] . There also exists a deterministic process described by an ordinary differential equation (ODE) as

which starts from q T ( x T ) and shares the same marginal distribution q t ( x t ) as the reverse SDE in Eq. (3). Moreover, let q 0 t ( x 0 | x t ) = q 0 t ( x t | x 0 ) q 0 ( x 0 ) q t ( x t ) and by Tweedie's formula [12], we know that α t E q 0 t ( x 0 | x t ) [ x 0 ] = x t + σ 2 t ∇ x t log q t ( x t ) .

2.2 Training paradigm of DPMs

To estimate the data score ∇ x t log q t ( x t ) at timestep t , a score-based model s t θ ( x t ) [46] with shared parameters θ is trained to minimize the score matching (SM) objective [20] as

To eliminate the intractable computation of ∇ x t log q t ( x t ) , denoising score matching (DSM) [49] transforms J t SM ( θ ) into J t DSM ( θ ) ≜ 1 2 E q 0 ( x 0 ) ,q ( ϵ ) [ ∥ ∥ ∥ s t θ ( x t ) + ϵ σ t ∥ ∥ ∥ 2 2 ] , where x t = α t x 0 + σ t ϵ and

q ( ϵ ) = N ( ϵ | 0 , I ) is a standard Gaussian distribution. Under mild boundary conditions, we know J t SM ( θ ) and J t DSM ( θ ) is equivalent up to a constant, i.e., J t SM ( θ ) = J t DSM ( θ ) + C t and C t is a constant independent of the model parameters θ . Other SM variants [31, 44] are also applicable here. The total SM objective for training is a weighted sum of J t SM ( θ ) across t ∈ [0 , T ] , defined as J SM ( θ ; λ ( t )) ≜ ∫ T 0 λ ( t ) J t SM ( θ ) dt , where λ ( t ) is a positive weighting function. Similarly, the total DSM objective is J DSM ( θ ; λ ( t )) ≜ ∫ T 0 λ ( t ) J t DSM ( θ ) dt . The training objectives under other model parametrizations such as noise prediction ϵ t θ ( x t ) [17, 33], data prediction x t θ ( x t ) [23, 32], and velocity prediction v t θ ( x t ) [18, 38] are recapped in Appendix B.1.

2.3 Likelihood of DPMs

Suppose that the reverse processes start from a tractable prior p T ( x T ) = N ( x T | 0 , ˜ σ 2 I ) . We can approximate the reverse-time SDE process by substituting ∇ x t log q t ( x t ) with s t θ ( x t ) in Eq. (3) as dx t = [ f ( t ) x t -g ( t ) 2 s t θ ( x t ) ] dt + g ( t ) dω t , which induces the marginal distribution p SDE t ( x t ; θ ) for t ∈ [0 , T ] . In particular, at t = 0 , the KL divergence between q 0 ( x 0 ) and p SDE 0 ( x 0 ; θ ) can be bounded by the total SM objective J SM ( θ ; g ( t ) 2 ) with the weighing function of g ( t ) 2 , as stated below:

Here D KL ( q T ∥ p T ) is the prior loss independent of θ . Similarly, we approximate the reverse-time ODE process by substituting ∇ x t log q t ( x t ) with s t θ ( x t ) in Eq. (4) as dx t dt = f ( t ) x t -1 2 g ( t ) 2 s t θ ( x t ) , which induces the marginal distribution p ODE t ( x t ; θ ) for t ∈ [0 , T ] . By the instantaneous change of variables formula [6], we have log p ODE t ( x t ; θ ) dt = -tr ( ∇ x t ( f ( t ) x t -1 2 g ( t ) 2 s t θ ( x t ) )) , where tr ( · ) denotes the trace of a matrix. Integrating change in log p ODE t ( x t ; θ ) from t = 0 to T can give the value of log p T ( x T ) -log p ODE 0 ( x 0 ; θ ) , but requires tracking the path from x 0 to x T . On the other hand, at t = 0 , the KL divergence between q 0 ( x 0 ) and p ODE 0 ( x 0 ; θ ) can be decomposed:

Lemma 1. (Proof in Song et al. [45]) Let q t ( x t ) be constructed from the forward process in Eq. (2). Then under regularity conditions, we have D KL ( q 0 ∥ p SDE 0 ( θ ) ) ≤ J SM ( θ ; g ( t ) 2 ) + D KL ( q T ∥ p T ) .

Lemma 2. (Proof in Lu et al. [28]) Let q t ( x t ) be constructed from the forward process in Eq. (2). Then under regularity conditions, we have D KL ( q 0 ∥ p ODE 0 ( θ ) ) = J SM ( θ ; g ( t ) 2 ) + D KL ( q T ∥ p T ) + J Diff ( θ ) , where the term J Diff ( θ ) measures the difference between s t θ ( x t ) and ∇ x t log p ODE t ( x t ; θ ) .

Directly computing J Diff ( θ ) is intractable due to the term ∇ x t log p ODE t ( x t ; θ ) , nevertheless, we could bound J Diff ( θ ) via bounding high-order SM objectives [28].

3 Calibrating pretrained DPMs

In this section we begin with deriving the relationship between data scores at different timesteps, which leads us to a straightforward method for calibrating any pretrained DPMs. We investigate further how the dataset bias of finite samples prevents empirical learning from achieving calibration.

3.1 The stochastic process of data score

According to Kingma et al. [23], the form of the forward process in Eq. (1) can be generalized to any two timesteps 0 ≤ s < t ≤ T . Then, the transition probability from x s to x t is written as q st ( x t | x s ) = N ( x t ∣ ∣ ∣ α t | s x s , σ 2 t | s I ) , where α t | s = α t α s and σ 2 t | s = σ 2 t -α 2 t | s σ 2 s . Here the marginal distribution satisfies q t ( x t ) = ∫ q st ( x t | x s ) q s ( x s ) dx s . We can generally derive the connection between data scores ∇ x t log q t ( x t ) and ∇ x s log q s ( x s ) as stated below:

Theorem 1. (Proof in Appendix A.1) Let q t ( x t ) be constructed from the forward process in Eq. (2). Then under some regularity conditions, we have ∀ 0 ≤ s < t ≤ T , where q st ( x s | x t ) = q st ( x t | x s ) q s ( x s ) q t ( x t ) is the transition probability from x t to x s .

Theorem 1 indicates that the stochastic process of α t ∇ x t log q t ( x t ) is a martingale w.r.t. the reversetime process of x t from timestep T to 0 . From the optional stopping theorem [14], the expected

value of a martingale at a stopping time is equal to its initial expected value E q 0 ( x 0 ) [ ∇ x 0 log q 0 ( x 0 )] . It is known that, under a mild boundary condition on q 0 ( x 0 ) , there is E q 0 ( x 0 ) [ ∇ x 0 log q 0 ( x 0 )] = 0 (proof is recapped in Appendix A.2). Consequently, as to the stochastic process, the martingale property results in E q t ( x t ) [ ∇ x t log q t ( x t )] = 0 for ∀ t ∈ [0 , T ] . Moreover, the martingale property of the (scaled) data score α t ∇ x t log q t ( x t ) leads to concentration bounds using Azuma's inequality and Doob's martingale inequality as derived in Appendix A.3. Although we do not use these concentration bounds further in this paper, there are other concurrent works that use roughly similar concentration bounds in diffusion models, such as proving consistency [47] or justifying trajectory retrieval [52].

3.2 A simple calibration trick

Given a pretrained model s t θ ( x t ) in practice, there is usually E q t ( x t ) [ s t θ ( x t )] = 0 , despite the fact that the expect data score is zero as E q t ( x t ) [ ∇ x t log q t ( x t )] = 0 . This motivates us to calibrate s t θ ( x t ) to s t θ ( x t ) -η t , where η t is a time-dependent calibration term that is independent of any particular input x t . The calibrated SM objective is written as follows:

̸

where the second equation holds after the results of E q t ( x t ) [ ∇ x t log q t ( x t )] = 0 , and there is J t SM ( θ, 0) = J t SM ( θ ) specifically when η t = 0 . Note that the orange part in Eq. (7) is a quadratic function w.r.t. η t . We look for the optimal η ∗ t = arg min η t J t SM ( θ, η t ) that minimizes the calibrated SM objective, from which we can derive

After taking η ∗ t into J t SM ( θ, η t ) , we have

Since there is J t SM ( θ ) = J t DSM ( θ ) + C t , we have J t DSM ( θ, η ∗ t ) = J t DSM ( θ ) -1 2 ∥ ∥ E q t ( x t ) [ s t θ ( x t )] ∥ ∥ 2 2 for the DSM objective. Similar calibration tricks are also valid under other model parametrizations and SM variants, as formally described in Appendix B.2.

Remark. For any pretrained score model s t θ ( x t ) , we can calibrate it into s t θ ( x t ) -E q t ( x t ) [ s t θ ( x t )] , which reduces the SM/DSM objectives at timestep t by 1 2 ∥ ∥ E q t ( x t ) [ s t θ ( x t )] ∥ ∥ 2 2 . The expectation of the calibrated score model is always zero, i.e., E q t ( x t ) [ s t θ ( x t ) -E q t ( x t ) [ s t θ ( x t )] ] = 0 holds for any θ , which is consistent with E q t ( x t ) [ ∇ x t log q t ( x t )] = 0 satisfied by data scores.

η t , there is s t θ ( x t ) -η t = ∇ x t log ( p t θ ( x t ) exp ( x ⊤ t η t ) Z t ( θ ) ) , where Z t ( θ ) = ∫ p t θ ( x t ) exp ( -x ⊤ t η t ) dx t represents the normalization factor. Intuitively, subtracting by η t corresponds to a shift in the vector space, so if s t θ ( x t ) is conservative, its calibrated version s t θ ( x t ) -η t is also conservative.

Calibration preserves conservativeness. A theoretical flaw of score-based modeling is that s t θ ( x t ) may not correspond to a probability distribution. To solve this issue, Salimans and Ho [37] develop an energy-based model design, which utilizes the power of score-based modeling and simultaneously makes sure that s t θ ( x t ) is conservative, i.e., there exists a probability distribution p t θ ( x t ) such that ∀ x t ∈ R k , we have s t θ ( x t ) = ∇ x t log p t θ ( x t ) . In this case, after we calibrate s t θ ( x t ) by subtracting

Conditional cases. As to the conditional DPMs, we usually employ a conditional model s t θ ( x t , y ) , where y ∈ Y is the conditional context (e.g., class label or text prompt). To learn the conditional data score ∇ x t log q t ( x t | y ) = ∇ x t log q t ( x t , y ) , we minimize the SM objective defined as J t SM ( θ ) ≜ 1 2 E q t ( x t ,y ) [ ∥ s t θ ( x t , y ) -∇ x t log q t ( x t , y ) ∥ 2 2 ] . Similar to the conclusion of E q t ( x t ) [ ∇ x t log q t ( x t )] = 0 , there is E q t ( x t | y ) [ ∇ x t log q t ( x t | y )] = 0 . To calibrate s t θ ( x t , y ) , we use the conditional term η t ( y ) and the calibrated SM objective is formulated as

and for any y ∈ Y , the optimal η ∗ t ( y ) is given by η ∗ t ( y ) = E q t ( x t | y ) [ s t θ ( x t , y )] . We highlight the conditional context y in contrast to the unconditional form in Eq. (7). After taking η ∗ t ( y ) into J t SM ( θ, η t ( y )) , we have J t SM ( θ, η ∗ t ( y )) = J t SM ( θ ) -1 2 E q t ( y ) [ ∥ ∥ E q t ( x t | y ) [ s t θ ( x t , y )] ∥ ∥ 2 2 ] . This conditional calibration form can naturally generalize to other model parametrizations and SM variants.

3.3 Likelihood of calibrated DPMs

Now we discuss the effects of calibration on model likelihood. Following the notations in Section 2.3, we use p SDE 0 ( θ, η t ) and p ODE 0 ( θ, η t ) to denote the distributions induced by the reverse-time SDE and ODE processes, respectively, where ∇ x t log q t ( x t ) is substituted with s t θ ( x t ) -η t .

Likelihood of p SDE 0 ( θ, η t ) . Let J SM ( θ, η t ; g ( t ) 2 ) ≜ ∫ T 0 g ( t ) 2 J t SM ( θ, η t ) dt be the total SM objective after the score model is calibrated by η t , then according to Lemma 1, we have D KL ( q 0 ∥ p SDE 0 ( θ, η t ) ) ≤ J SM ( θ, η t ; g ( t ) 2 ) + D KL ( q T ∥ p T ) . From the result in Eq. (9), there is

Therefore, the likelihood D KL ( q 0 ∥ p SDE 0 ( θ, η ∗ t ) ) after calibration has a lower upper bound of J SM ( θ, η ∗ t ; g ( t ) 2 ) + D KL ( q T ∥ p T ) , compared to the bound of J SM ( θ ; g ( t ) 2 ) + D KL ( q T ∥ p T ) for the original D KL ( q 0 ∥ p SDE 0 ( θ ) ) . However, we need to clarify that D KL ( q 0 ∥ p SDE 0 ( θ, η ∗ t ) ) may not necessarily smaller than D KL ( q 0 ∥ p SDE 0 ( θ ) ) , since we can only compare their upper bounds.

D KL ( q 0 ∥ p ODE 0 ( θ, η t ) ) ≈ J SM ( θ, η t ; g ( t ) 2 ) + D KL ( q T ∥ p T ) , and D KL ( q 0 ∥ p ODE 0 ( θ, η ∗ t ) ) approximately achieves its lowest value. Lu et al. [28] show that D KL ( q 0 ∥ p ODE 0 ( θ ) ) can be further bounded by high-order SM objectives (as detailed in Appendix A.4), which depend on ∇ x t s t θ ( x t ) and ∇ x t tr ( ∇ x t s t θ ( x t )) . Since the calibration term η t is independent of x t , i.e., ∇ x t η t = 0 , it does not affect the values of high-order SM objectives, and achieves a lower upper bound due to the lower value of the first-order SM objective.

Likelihood of p ODE 0 ( θ, η t ) . Note that in Lemma 2, there is a term J Diff ( θ ) , which is usually small in practice since s t θ ( x t ) and ∇ x t log p ODE t ( x t ; θ ) are close. Thus, we have

3.4 Empirical learning fails to achieve E q t ( x t ) [ s t θ ( x t )] = 0

A question that naturally arises is whether better architectures or learning algorithms for DPMs (e.g., EDMs [22]) could empirically achieve E q t ( x t ) [ s t θ ( x t )] = 0 without calibration? The answer may be negative, since in practice we only have access to a finite dataset sampled from q 0 ( x 0 ) . More specifically, assuming that we have a training dataset D ≜ { x n 0 } N n =1 where x n 0 ∼ q 0 ( x 0 ) , and defining the kernel density distribution induced by D as q t ( x t ; D ) ∝ ∑ N n =1 N ( x t -α t x n 0 σ t ∣ ∣ 0 , I ) . When the quantity of training data approaches infinity, we have lim N →∞ q t ( x t ; D ) = q t ( x t ) holds for t [0 , T ] . Then the empirical DSM objective trained on is written as

∀ ∈ D

and it is easy to show that the optimal solution for minimizing J t DSM ( θ ; D ) satisfies (assuming s t θ has universal model capacity) s t θ ( x t ) = ∇ x t log q t ( x t ; D ) . Given a finite dataset D , there is

indicating that even if the score model is learned to be optimal, there is still E q t ( x t ) [ s t θ ( x t )] = 0 . Thus, the mis-calibration of DPMs is partially due to the dataset bias , i.e., during training we can only access a finite dataset D sampled from q 0 ( x 0 ) .

̸

̸

̸

̸

Furthermore, when trained on a finite dataset in practice, the learned model will not converge to the optimal solution [15], so there is typically s t θ ( x t ) = ∇ x t log q t ( x t ; D ) and E q t ( x t ; D ) [ s t θ ( x t )] = 0 . After calibration, we can at least guarantee that E q t ( x t ; D ) [ s t θ ( x t ) -E q t ( x t ; D ) [ s t θ ( x t )] ] = 0 always holds on any finite dataset D . In Figure 3, we demonstrate that even state-of-the-art EDMs still have non-zero and semantic E q t ( x t ) [ s t θ ( x t )] , which emphasises the significance of calibrating DPMs.

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

100

200

300

400

500

g

(

t

)

2

2

σ

2

t

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

100

200

300

400

500

g

(

t

)

2

2

σ

2

t

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

200

400

600

800 1000

Timestep

0

.

04

0

.

06

0

.

08

0

.

10

0

.

12

1

2

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

200

400

600

800 1000

Timestep

0

5

10

15

g

(

t

)

2

2

σ

2

t

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

200

400

600

800 1000

Timestep

1

2

3

g

(

t

)

2

2

σ

2

t

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

200

400

600

800 1000

Timestep

0

.

025

0

.

030

0

.

035

0

.

040

1

2

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

.

20

0

.

25

0

.

30

0

.

35

0

.

40

1

2

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

.

080

0

.

085

0

.

090

1

2

‖

E

q

t

(

x

t

)

[

/epsilon1

t

θ

(

xt

)]

‖

2

2

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

5

10

15

20

1

2

E

q

t

(

y

)

[

‖

E

q

t

(

x

t

|

y

)

[

/epsilon1

t

θ

(

xt, y

)]

‖

2

2

]

0

.

0

0

.

2

0

.

4

0

.

6

0

.

8

1

.

0

Timestep

0

100

200

300

400

500

g

(

t

)

2

2

σ

2

t

E

q

t

(

y

)

[

‖

E

q

t

(

x

t

|

y

)

[

/epsilon1

t

θ

(

xt, y

)]

‖

2

2

]

ImageNet 64

×

64

FFHQ 64

×

64

×

64

CelebA 64

×

64

CIFAR-10

3.5 Amortized computation of E q t ( x t ) [ s t θ ( x t )]

By default, we are able to calculate and restore the value of E q t ( x t ) [ s t θ ( x t )] for a pretrained model s t θ ( x t ) , where the selection of timestep t is determined by the inference algorithm, and the expectation over q t ( x t ) can be approximated by Monte Carlo sampling from a noisy training set. When we do not have access to training data, we can approximate the expectation using data generated from p ODE t ( x t ; θ ) or p SDE t ( x t ; θ ) . Since we only need to calculate E q t ( x t ) [ s t θ ( x t )] once, the raised computational overhead is amortized as the number of generated samples increases.

Dynamically recording. In the preceding context, we focus primarily on post-training computing of E q t ( x t ) [ s t θ ( x t )] . An alternative strategy would be to dynamically record E q t ( x t ) [ s t θ ( x t )] during the pretraining phase of s t θ ( x t ) . Specifically, we could construct an auxiliary shallow network h ϕ ( t ) parameterized by ϕ , whose input is the timestep t . We define the expected mean squared error as

where the superscript † denotes the stopping gradient and ϕ ∗ is the optimal solution of minimizing J t Cal ( ϕ ) w.r.t. ϕ , satisfying h ϕ ∗ ( t ) = η ∗ t = E q t ( x t ) [ s t θ ( x t )] (assuming sufficient model capacity). The total training objective can therefore be expressed as J SM ( θ ; λ ( t )) + ∫ T 0 β t · J t Cal ( ϕ ) , where β t is a time-dependent trade-off coefficient for t ∈ [0 , T ] .

4 Experiments

In this section, we demonstrate that sample quality and model likelihood can be both improved by calibrating DPMs. Instead of establishing a new state-of-the-art, the purpose of our empirical studies is to testify the efficacy of our calibration technique as a simple way to repair DPMs.

4.1 Sample quality

Setup. We apply post-training calibration to discrete-time models trained on CIFAR-10 [25] and CelebA [27], which apply parametrization of noise prediction ϵ t θ ( x t ) . In the sampling phase, we employ DPM-Solver [29], an ODE-based sampler that achieves a promising balance between sample efficiency and image quality. Because our calibration directly acts on model scores, it is also compatible with other ODE/SDE-based samplers [3, 26], while we only focus on DPM-Solver cases in this paper. In accordance with the recommendation, we set the end time of DPM-Solver to 10 -3 when the number of sampling steps is less than 15 , and to 10 -4 otherwise. Additional details can be

found in Lu et al. [29]. By default, we employ the FID score [16] to quantify the sample quality using 50,000 samples. Typically, a lower FID indicates a higher sample quality. In addition, in Table 3, we evaluate using other metrics such as sFID [30], IS [39], and Precision/Recall [36].

Computing E q t ( x t ) [ ϵ t θ ( x t )] . To estimate the expectation over q t ( x t ) , we construct x t = α t x 0 + σ t ϵ , where x 0 ∼ q 0 ( x 0 ) is sampled from the training set and ϵ ∼ N ( ϵ | 0 , I ) is sampled from a standard Gaussian distribution. The selection of timestep t depends on the sampling schedule of DPM-Solver. The computed values of E q t ( x t ) [ ϵ t θ ( x t )] are restored in a dictionary and warped into the output layers of DPMs, allowing existing inference pipelines to be reused.

We first calibrate the model trained by Ho et al. [17] on the CIFAR-10 dataset and compare it to the original one for sampling with DPM-Solvers. We conduct a systematical study with varying NFE (i.e., number of function evaluations) and solver order. The results are presented in Tables 1 and 3. After calibrating the model, the sample quality is consistently enhanced, which demonstrates the significance of doing so and the efficacy of our method. We highlight the significant improvement in sample quality (4.61 → 4.22 when using 15 NFE and 3 -order DPM-Solver; 3.89 → 3.32 when using 20 NFE and 3 -order DPM-Solver). After model calibration, the number of steps required to achieve convergence for a 3 -order DPM-Solver is reduced from ≥ 30 to 20, making our method a new option for expediting the sampling of DPMs. In addition, as a point of comparison, the 3 -order DPM-Solver with 1,000 NFE can only yield an FID score of 3.45 when using the original model, which, along with the results in Table 1, indicates that model calibration helps to improve the convergence of sampling.

Then, we conduct experiments with the discrete-time model trained on the CelebA 64x64 dataset by Song et al. [41]. The corresponding sample quality comparison is shown in Table 2. Clearly, model calibration brings significant gains (3.91 → 3.62 when using 15 NFE and 3 -order DPM-Solver; 2.84 → 2.33 when using 20 NFE and 3 -order DPM-Solver) that are consistent with those on the CIFAR-10 dataset. This demonstrates the prevalence of the mis-calibration issue in existing DPMs and the efficacy of our correction. We still observe that model calibration improves convergence of sampling, and as shown in Figure 2, our calibration could help to reduce ambiguous generations. More generated images are displayed in Appendix C.

w/ calibration (

Method

Number of evaluations (NFE)

20

25

30

FID sFID

IS

Pre.

Rec.

FID sFID

IS

Pre.

Rec.

FID sFID

IS

Pre.

Rec.

Base

1

-ord. 9.72

6.03

8.49 0.641 0.542 7.89

5.45

8.68 0.644 0.556 6.84

5.12

8.76 0.650 0.565

2

-ord. 4.14

4.36

9.15 0.654 0.590 3.92

4.22

9.17 0.657 0.591 3.74

4.18

9.20 0.658 0.591

3

-ord. 3.89

4.18

9.29 0.652 0.597 3.73

4.15

9.21 0.657 0.595 3.65

4.12

9.22 0.658 0.593

Ours

1

-ord. 8.86

6.01

8.56 0.649 0.544 7.35

5.42

8.76 0.653 0.560 6.28

5.09

8.84 0.653 0.568

2

-ord. 4.03

4.31

9.17

0.661

0.592 3.66

4.20

9.20 0.664 0.594 3.54

4.14

9.23

0.662

0.599

3

-ord.

3.32

4.14

9.38

0.657

0.603 3.33

4.11

9.28 0.665 0.597 3.35

4.08

9.27 0.662 0.600

w/o calibration (

baseline

)

ours

)

4.2 Model likelihood

As described in Section 3.3, calibration contributes to reducing the SM objective, thereby decreasing the upper bound of the KL divergence between model distribution at timestep t = 0 (either p SDE 0 ( θ, η ∗ t ) or p ODE 0 ( θ, η ∗ t ) ) and data distribution q 0 . Consequently, it aids in raising the lower bound of model likelihood. In this subsection, we examine such effects by evaluating the aforementioned DPMs on the CIFAR-10 and CelebA datasets. We also conduct experiments with continuous-time models trained by Karras et al. [22] on AFHQv2 64 × 64 [7], FFHQ 64 × 64 [21], and ImageNet 64 × 64 [9] datasets considering their top performance. These models apply parametrization of data prediction x t θ ( x t ) , and for consistency, we convert it to align with ϵ t θ ( x t ) based on the relationship ϵ t θ ( x t ) = ( x t -α t x t θ ( x t )) /σ t , as detailed in Kingma et al. [23] and Appendix B.2.

Given that we employ noise prediction models in practice, we first estimate 1 2 ∥ E q t ( x t ) [ ϵ t θ ( x t )] ∥ 2 2 at timestep t ∈ [0 , T ] , which reflects the decrement on the SM objective at t according to Eq. (9) (up to a scaling factor of 1 /σ 2 t ). We approximate the expectation using Monte Carlo (MC) estimation with training data points. The results are displayed in the first row of Figure 1. Notably, the value of 1 2 ∥ E q t ( x t ) [ ϵ t θ ( x t )] ∥ 2 2 varies significantly along with timestep t : it decreases relative to t for CelebA but increases in all other cases (except for t ∈ [0 . 4 , 1 . 0] on ImageNet 64 × 64). Ideally, there should be 1 2 ∥ E q t ( x t ) [ ∇ x t log q t ( x t )] ∥ 2 2 = 0 at any t . Such inconsistency reveals that mis-calibration issues exist in general, although the phenomenon may vary across datasets and training mechanisms.

Then, we quantify the gain of model calibration on increasing the lower bound of model likelihood, which is 1 2 ∫ T 0 g ( t ) 2 ∥ ∥ E q t ( x t ) [ s t θ ( x t )] ∥ ∥ 2 2 dt according to Eq. (11). We first rewrite it with the model parametrization of noise prediction ϵ t θ ( x t ) , and it can be straightforwardly demonstrated that it equals ∫ T 0 g ( t ) 2 2 σ 2 t ∥ E q t ( x t ) [ ϵ t θ ( x t )] ∥ 2 2 . Therefore, we calculate the value of g ( t ) 2 2 σ 2 t ∥ E q t ( x t ) [ ϵ t θ ( x t )] ∥ 2 2 using MC

CelebA 64

×

64

FFHQ 64

×

64

Timestep

𝑡

0

𝑇

estimation and report the results in the second row of Figure 1. The integral is represented by the area under the curve (i.e., the gain of model calibration on the lower bound of model likelihood). Various datasets and model architectures exhibit non-trivial gains, as observed. In addition, we notice that the DPMs trained by Karras et al. [22] show patterns distinct from those of DDPM [17] and DDIM [41], indicating that different DPM training mechanisms may result in different mis-calibration effects.

Visualizing E q t ( x t ) [ ϵ t θ ( x t )] . To better understand the inductive bias learned by DPMs, we visualize the expected predicted noises E q t ( x t ) [ ϵ t θ ( x t )] for timestep from 0 to T , as seen in Figure 3. For each dataset, the first row normalizes the values of E q t ( x t ) [ ϵ t θ ( x t )] into [0 , 255] ; the second row calculates pixel-wise norm (across RGB channels) and highlights the top10% locations with the highest norm. As we can observe, on facial datasets like CelebA and FFHQ, there are obvious facial patterns inside E q t ( x t ) [ ϵ t θ ( x t )] , while on other datasets like CIFAR-10, ImageNet, as well as the animal face dataset AFHQv2, the patterns inside E q t ( x t ) [ ϵ t θ ( x t )] are more like random noises. Besides, the facial patterns in Figure 3 are more significant when t is smaller, and become blurry when t is close to T . This phenomenon may be attributed to the bias of finite training data, which is detrimental to generalization during sampling and justifies the importance of calibration as described in Section 3.4.

4.3 Ablation studies

We conduct ablation studies focusing on the estimation methods of E q t ( x t ) [ ϵ t θ ( x t )] .

Estimating E q t ( x t ) [ ϵ t θ ( x t )] with partial training data. In the post-training calibration setting, our primary algorithmic change is to subtract the calibration term E q t ( x t ) [ ϵ t θ ( x t )] from the pretrained DPMs' output. In the aforementioned studies, the expectation in E q t ( x t ) [ ϵ t θ ( x t )] (or its variant of other model parametrizations) is approximated with MC estimation using all training images. However, there may be situations where training data are (partially) inaccessible. To evaluate the effectiveness of our method under these cases, we examine the number of training images used to estimate the calibration term on CIFAR-10. To determine the quality of the estimated calibration term, we sample from the calibrated models using a 3 -order DPM-Solver running for 20 steps and evaluate the corresponding FID score. The results are listed in the left part of Table 4. As observed, we need to use the majority of training images (at least ≥ 20,000) to estimate the calibration term. We deduce that this is because the CIFAR-10 images are rich in diversity, necessitating a non-trivial number of training images to cover the various modes and produce a nearly unbiased calibration term.

Estimating E q t ( x t ) [ ϵ t θ ( x t )] with generated data. In the most extreme case where we do not have access to any training data (e.g., due to privacy concerns), we could still estimate the expectation over q t ( x t ) with data generated from p ODE 0 ( x 0 ; θ ) or p SDE 0 ( x 0 ; θ ) . Specifically, under the hypothesis that p ODE 0 ( x 0 ; θ ) ≈ q 0 ( x 0 ) (DPM-Solver is an ODE-based sampler), we first generate ˜ x 0 ∼ p ODE 0 ( x 0 ; θ )

0

200

400

600

800

1000

0.2

0.3

0.4

0.5

0.6

0.7

0.8

Mean Square Error

t=0

t=250

t=500

t=750

t=999

and construct ˜ x t = α t ˜ x 0 + σ t ϵ , where ˜ x t ∼ p ODE t ( x t ; θ ) . Then, the expectation over q t ( x t ) could be approximated by the expectation over p ODE t ( x t ; θ ) .

Empirically, on the CIFAR-10 dataset, we adopt a 3 -order DPM-Solver to generate a set of samples from the pretrained model of Ho et al. [17], using a relatively large number of sampling steps (e.g., 50 steps). This set of generated data is used to calculate the calibration term E q t ( x t ) [ ϵ t θ ( x t )] . Then, we obtain the calibrated model ϵ t θ ( x t ) -E q t ( x t ) [ ϵ t θ ( x t )] and craft new images based on a 3 -order 20-step DPM-Solver. In the right part of Table 4, we present the results of an empirical investigation into how the number of generated images influences the quality of model calibration.

Using the same sampling setting, we also provide two reference points: 1) the originally mis-calibrated model can reach the FID score of 3.89, and 2) the model calibrated with training data can reach the FID score of 3.32. Comparing these results reveals that the DPM calibrated with a large number of high-quality generations can achieve comparable FID scores to those calibrated with training samples (see the result of using 20,000 generated images). Additionally, it appears that using more generations is not advantageous. This may be because the generations from DPMs, despite being known to cover diverse modes, still exhibit semantic redundancy and deviate slightly from the data distribution.

Dynamical recording. We simulate the proposed dynamical recording technique. Specifically, we use a 3 -layer MLP of width 512 to parameterize the aforementioned network h ϕ ( t ) and train it with an Adam optimizer [24] to approximate the expected predicted noises E q t ( x t ) [ ϵ t θ ( x t )] , where ϵ t θ ( x t ) comes from the pretrained noise prediction model on CIFAR-10 [17]. The training of h ϕ ( t ) runs for 1,000 epochs. Meanwhile, using the training data, we compute the expected predicted noises with MCestimation and treat them as the ground truth. In Figure 4, we compare them to the outputs of h ϕ ( t ) and visualize the disparity measured by mean square error. As demonstrated, as the number of training epochs increases, the network h ϕ ( t ) quickly converges and can form a relatively reliable approximation to the ground truth. Dynamic recording has a distinct advantage of being able to be performed during the training of DPMs to enable immediate generation. We clarify that better timestep embedding techniques and NN architectures can improve approximation quality even further.

5 Discussion

We propose a straightforward method for calibrating any pretrained DPM that can provably reduce the values of SM objectives and, as a result, induce higher values of lower bounds for model likelihood. We demonstrate that the mis-calibration of DPMs may be inherent due to the dataset bias and/or sub-optimally learned model scores. Our findings also provide a potentially new metric for assessing a diffusion model by its degree of 'uncalibration', namely, how far the learned scores deviate from the essential properties (e.g., the expected data scores should be zero).

Limitations. While our calibration method provably improves the model's likelihood, it does not necessarily yield a lower FID score, as previously discussed [45]. Besides, for text-to-image generation, post-training computation of E q t ( x t | y ) [ s t θ ( x t , y )] becomes infeasible due to the exponentially large number of conditions y , necessitating dynamic recording with multimodal modules.

References

Kazuoki Azuma. Weighted sums of certain dependent random variables. Tohoku Mathematical Journal, Second Series , 19(3):357-367, 1967.

Arpit Bansal, Eitan Borgnia, Hong-Min Chu, Jie S Li, Hamid Kazemi, Furong Huang, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Cold diffusion: Inverting arbitrary image transforms without noise. arXiv preprint arXiv:2208.09392 , 2022.

Fan Bao, Chongxuan Li, Jun Zhu, and Bo Zhang. Analytic-dpm: an analytic estimate of the optimal reverse variance in diffusion probabilistic models. In International Conference on Learning Representations (ICLR) , 2022.

Ruojin Cai, Guandao Yang, Hadar Averbuch-Elor, Zekun Hao, Serge Belongie, Noah Snavely, and Bharath Hariharan. Learning gradient fields for shape generation. In European Conference on Computer Vision (ECCV) , 2020.

Nanxin Chen, Yu Zhang, Heiga Zen, Ron J Weiss, Mohammad Norouzi, and William Chan. Wavegrad: Estimating gradients for waveform generation. In International Conference on Learning Representations (ICLR) , 2021.

Ricky TQ Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary differential equations. In Advances in Neural Information Processing Systems (NeurIPS) , 2018.

Yunjey Choi, Youngjung Uh, Jaejun Yoo, and Jung-Woo Ha. Stargan v2: Diverse image synthesis for multiple domains. In IEEE International Conference on Computer Vision (CVPR) , 2020.

Giannis Daras, Mauricio Delbracio, Hossein Talebi, Alexandros G Dimakis, and Peyman Milanfar. Soft diffusion: Score matching for general corruptions. arXiv preprint arXiv:2209.05442 , 2022.

Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , 2009.

Prafulla Dhariwal and Alexander Nichol. Diffusion models beat gans on image synthesis. In Advances in Neural Information Processing Systems (NeurIPS) , 2021.

Joseph L Doob and Joseph L Doob. Stochastic processes , volume 7. Wiley New York, 1953.

Bradley Efron. Tweedie's formula and selection bias. Journal of the American Statistical Association , 106(496):1602-1614, 2011.

Rinon Gal, Yuval Alaluf, Yuval Atzmon, Or Patashnik, Amit H Bermano, Gal Chechik, and Daniel Cohen-Or. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618 , 2022.

Geoffrey Grimmett and David Stirzaker. Probability and random processes . Oxford university press, 2001.

Xiangming Gu, Chao Du, Tianyu Pang, Chongxuan Li, Min Lin, and Ye Wang. On memorization in diffusion models. arXiv preprint arXiv:2310.02664 , 2023.

Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In Advances in Neural Information Processing Systems (NeurIPS) , pages 6626-6637, 2017.

Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. In Advances in Neural Information Processing Systems (NeurIPS) , 2020.

Jonathan Ho, William Chan, Chitwan Saharia, Jay Whang, Ruiqi Gao, Alexey Gritsenko, Diederik P Kingma, Ben Poole, Mohammad Norouzi, David J Fleet, et al. Imagen video: High definition video generation with diffusion models. arXiv preprint arXiv:2210.02303 , 2022.

Jonathan Ho, Tim Salimans, Alexey Gritsenko, William Chan, Mohammad Norouzi, and David J Fleet. Video diffusion models. arXiv preprint arXiv:2204.03458 , 2022.

Aapo Hyv¨ arinen. Estimation of non-normalized statistical models by score matching. Journal of Machine Learning Research (JMLR) , 6(Apr):695-709, 2005.

Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In IEEE International Conference on Computer Vision (CVPR) , 2019.

Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusion-based generative models. In Advances in Neural Information Processing Systems (NeurIPS) , 2022.

Diederik Kingma, Tim Salimans, Ben Poole, and Jonathan Ho. Variational diffusion models. In Advances in Neural Information Processing Systems (NeurIPS) , 2021.

Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980 , 2014.

Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.

Luping Liu, Yi Ren, Zhijie Lin, and Zhou Zhao. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations (ICLR) , 2022.

Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang. Deep learning face attributes in the wild. In International Conference on Computer Vision (ICCV) , 2015.

Cheng Lu, Kaiwen Zheng, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Maximum likelihood training for score-based diffusion odes by high order denoising score matching. In International Conference on Machine Learning (ICML) , 2022.

Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. Dpm-solver: A fast ode solver for diffusion probabilistic model sampling in around 10 steps. In Advances in Neural Information Processing Systems (NeurIPS) , 2022.

Charlie Nash, Jacob Menick, Sander Dieleman, and Peter W Battaglia. Generating images with sparse representations. arXiv preprint arXiv:2103.03841 , 2021.

Tianyu Pang, Kun Xu, Chongxuan Li, Yang Song, Stefano Ermon, and Jun Zhu. Efficient learning of generative models via finite-difference score matching. In Advances in Neural Information Processing Systems (NeurIPS) , 2020.

Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, and Mark Chen. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125 , 2022.

Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Bj¨ orn Ommer. Highresolution image synthesis with latent diffusion models. In IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , 2022.

Nataniel Ruiz, Yuanzhen Li, Varun Jampani, Yael Pritch, Michael Rubinstein, and Kfir Aberman. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242 , 2022.

Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mohammad Norouzi. Image super-resolution via iterative refinement. IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI) , 2022.

Mehdi SM Sajjadi, Olivier Bachem, Mario Lucic, Olivier Bousquet, and Sylvain Gelly. Assessing generative models via precision and recall. In Advances in Neural Information Processing Systems (NeurIPS) , 2018.

Tim Salimans and Jonathan Ho. Should ebms model the energy or the score? In Energy Based Models Workshop-ICLR , 2021.

Tim Salimans and Jonathan Ho. Progressive distillation for fast sampling of diffusion models. In International Conference on Learning Representations (ICLR) , 2022.

Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. In Advances in Neural Information Processing Systems (NeurIPS) , 2016.

Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning (ICML) , pages 2256-2265. PMLR, 2015.

Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations (ICLR) , 2021.

Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems (NeurIPS) , pages 1189511907, 2019.

Yang Song and Stefano Ermon. Improved techniques for training score-based generative models. In Advances in Neural Information Processing Systems (NeurIPS) , 2020.

Yang Song, Sahaj Garg, Jiaxin Shi, and Stefano Ermon. Sliced score matching: A scalable approach to density and score estimation. In Conference on Uncertainty in Artificial Intelligence (UAI) , 2019.

Yang Song, Conor Durkan, Iain Murray, and Stefano Ermon. Maximum likelihood training of score-based diffusion models. In Advances in Neural Information Processing Systems (NeurIPS) , 2021.

Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. In International Conference on Learning Representations (ICLR) , 2021.

Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever. Consistency models. arXiv preprint arXiv:2303.01469 , 2023.

Arash Vahdat, Karsten Kreis, and Jan Kautz. Score-based generative modeling in latent space. In Advances in Neural Information Processing Systems (NeurIPS) , 2021.

Pascal Vincent. A connection between score matching and denoising autoencoders. Neural computation , 23(7):1661-1674, 2011.

Zekai Wang, Tianyu Pang, Chao Du, Min Lin, Weiwei Liu, and Shuicheng Yan. Better diffusion models further improve adversarial training. In International Conference on Machine Learning (ICML) , 2023.

Minkai Xu, Lantao Yu, Yang Song, Chence Shi, Stefano Ermon, and Jian Tang. Geodiff: A geometric diffusion model for molecular conformation generation. In International Conference on Learning Representations (ICLR) , 2022.

Kexun Zhang, Xianjun Yang, William Yang Wang, and Lei Li. Redi: Efficient learning-free diffusion inference via trajectory retrieval. arXiv preprint arXiv:2302.02285 , 2023.

A Detailed derivations

In this section, we provide detailed derivations for the Theorem and equations shown in the main text. We follow the regularization assumptions listed in Song et al. [45].

A.1 Proof of Theorem 1

Proof. For any two timesteps 0 ≤ s < t ≤ T , i.e., the transition probability from x s to x t is written as q st ( x t | x s ) = N ( x t ∣ ∣ ∣ α t | s x s , σ 2 t | s I ) , where α t | s = α t α s and σ 2 t | s = σ 2 t -α 2 t | s σ 2 s . The marginal distribution q t ( x t ) = ∫ q st ( x t | x s ) q s ( x s ) dx s and we have

Note that when the transition probability q st ( x t | x s ) corresponds to a well-defined forward process, there is α t > 0 for ∀ t ∈ [0 , T ] , and thus we achieve α t ∇ x t log q t ( x t ) = E q st ( x s | x t ) [ α s ∇ x s log q s ( x s )] .

Proof. The input variable x ∈ R k and q 0 ( x 0 ) ∈ C 2 , where C 2 denotes the family of functions with continuous second-order derivatives. 1 We use x i denote the i -th element of x , then we can derive the expectation

where x \ i 0 denotes all the k -1 elements in x 0 except for the i -th one. The last equation holds under the boundary condition that lim x i 0 →∞ q 0 ( x i 0 ) = 0 hold for any i ∈ [ K ] . Thus, we achieve the conclusion that E q 0 ( x 0 ) [ ∇ x 0 log q 0 ( x 0 )] = 0 .

A.3 Concentration bounds

We describe concentration bounds [11, 1] of the martingale α t ∇ x t log q t ( x t ) .

Azuma's inequality. For discrete reverse timestep t = T, T -1 , · · · , 0 , Assuming that there exist constants 0 < c 1 , c 2 , · · · , < ∞ such that for the i -th element of x , almost surely. Then ∀ ϵ > 0 , the probability (note that α 0 = 1 )

Specially, considering that q T ( x T ) ≈ N ( x T | 0 , ˜ σ 2 I ) , there is ∂ ∂x i T log q T ( x T ) ≈ -x i T ˜ σ 2 . Thus, we can approximately obtain

Doob's inequality. For continuous reverse timestep t from T to 0 , if the sample paths of the martingale are almost surely right-continuous, then for the i -th element of x we have (note that α 0 = 1 )

A.4 High-order SM objectives

where J Fisher ( θ ) is a weighted sum of Fisher divergence between q t ( x t ) and p ODE t ( θ ) as

Moreover, Lu et al. [28] prove that if ∀ t ∈ [0 , T ] and ∀ x t ∈ R k , there exist a constant C F such that the spectral norm of Hessian matrix ∥∇ 2 x t log p ODE t ( x t ; θ ) ∥ 2 ≤ C F , and there exist δ 1 , δ 2 , δ 3 > 0 such that

̸

The case after calibration. When we impose the calibration term η ∗ t = E q t ( x t ) [ s t θ ( x t )] to get the score model s t θ ( x t ) -η ∗ t , there is ∇ x t η ∗ t = 0 and thus ∇ x t ( s t θ ( x t ) -η ∗ t ) = ∇ x t s t θ ( x t ) . Then we have where ∥ · ∥ F is the Frobenius norm of matrix. Then there exist a function U ( t ; δ 1 , δ 2 , δ 3 , q ) that independent of θ and strictly increasing (if g ( t ) = 0 ) w.r.t. δ 1 , δ 2 , and δ 3 , respectively, such that the Fisher divergence can be bounded as D F ( q t ∥ p ODE t ( θ ) ) ≤ U ( t ; δ 1 , δ 2 , δ 3 , q ) .

From these, we know that the Fisher divergence D F ( q t ∥ p ODE t ( θ, η ∗ t ) ) ≤ U ( t ; δ ′ 1 , δ 2 , δ 3 , q ) ≤ U ( t ; δ 1 , δ 2 , δ 3 , q ) , namely, D F ( q t ∥ p ODE t ( θ, η ∗ t ) ) has a lower upper bound compared to D F ( q t ∥ p ODE t ( θ ) ) . Consequently, we can get lower upper bounds for both J Fisher ( θ, η ∗ t ) and D KL ( q 0 ∥ p ODE 0 ( θ, η ∗ t ) ) , compared to J Fisher ( θ ) and D KL ( q 0 ∥ p ODE 0 ( θ ) ) , respectively. B Model parametrization

This section introduces different parametrizations used in diffusion models and provides their calibrated instantiations.

B.1 Preliminary

Along the research routine of diffusion models, different model parametrizations have been used, including score prediction s t θ ( x t ) [42, 46], noise prediction ϵ t θ ( x t ) [17, 33], data prediction x t θ ( x t ) [23, 32], and velocity prediction v t θ ( x t ) [38, 18]. Taking the DSM objective as the training loss, its instantiation at timestep t ∈ [0 , T ] is written as

Under different model parametrizations, we can derive the optimal calibration terms η ∗ t that minimizing J t DSM ( θ, η t ) as

Taking η ∗ t into J t DSM ( θ, η t ) we can obtain the gap

We further show generated images in Figure 5 to double confirm the efficacy of our calibration method. Our calibration could help to reduce ambiguous generations on both CIFAR-10 and CelebA.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper investigates calibrating diffusion models. They notice that the expected data score equals zero. Since models not usually do not learn this correctly, they introduce a calibration term to subtract from a learned score. The new objective now includes the expected model score and performs better compared to the uncalibrated models.\n\nSTRENGTHS:\nThe paper is well written and the method is presented clearly. The theoretical results are convincing. The main appeal of the method is its simplicity. The solver part of the results is solid.\n\nWEAKNESSES:\nSince the focus is on post-processing, the method is best suited for discrete time diffusion (like DDPM). Otherwise, it is unclear how the expected values are saved for continuous t. Line 221 mentions the selection of t depends on the sampling schedule of the solver, but the solver then cannot be adaptive. The alternative of learning the network as in eq. 14 would solve this but seems overly complicated. As can be seen from Fig 1 the lines are simple so fitting some simpler model would make more sense.\n\nThe results are showing the number of solver evaluations is lower and the likelihood is better. Likelihood is evaluated in a weird way. The only thing that is shown is that the expected learned score is not zero for \"uncalibrated\" models which is somewhat tautological. In this case, some other relevant metric like FID would be better.\n\nThere is no empirical demonstration that the diffusion models are uncalibrated, in a similar way that confidence-accuracy diagrams show this for classification. One could learn some simple synthetic dataset from a known distribution.\n\nIt is not clear why this would be a relevant task, as presented. I assume guidance would further uncalibrate the models but it is used for better samples. Perhaps the image domain is not the best choice here.\n\nEq. 13 is presented as a fact, whereas it seems this is to be demonstrated.\n\nThe main issue is the limited motivation for improving generative models on likelihood and a bad choice of experimental setup. Something other than images could solve both of these issues.\n\nQUESTIONS:\n- Why is FID going up with the number of samples in Table 3 in both columns?\n\n- Can you incorporate this loss somehow during training so that the final model is calibrated?\n\n- Does this hold for any data distribution?\n\n- Could using 20 and 50 diffusion steps for generation be too little?\n\nLIMITATIONS:\nLimitations are addressed.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-05"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe paper proposes a simple procedure to improve the calibration of pre-trained diffusion models. \n\nDiffusion models have achieved strong practical performance, but its score estimation is often seen as a black box. The paper sheds some light on the issue, by detecting the inherent lack of calibration of the current state-of-the-art models, and proposing a simple procedure that reliably drives up the lower bound for model likelihood. Empirical evaluations showcase the efficacy of the method.\n\nSTRENGTHS:\nThe paper discusses the problem of calibration in diffusion models, a question long overdue in this area of research: while diffusion models have achieved eye-catching generative results, little is known about whether the score function is a loyal depiction of the ground truth, or even a gradient field in itself. \n\nThe paper gives theoretically sound justifications of by framing the evolution of the score function as a martingale, and proposes a simple yet empirically quite effective way that adjust pre-trained diffusion models closer to the underlying score function. The overall writing and presentation of the paper is sound.\n\nWEAKNESSES:\nI think Section 3.4 is unsatisfactory, as I think the proper conclusion should be that the uncalibrated DPM training objective do not inherently minimize the mean of the expected predicted noises. My 2 more specific comments are listed below. \n\n- The logic between the explanations in 3.4 and Figure 2 seems confounding. I have understood the main points made in the paper after several reads, so I think the paper could adopt an easier to follow explanation. I believe the author's main point is (i) the optimal score attainable via diffusion modeling is capped by finite training data, so while the optimal score $\\nabla \\log q_t(x_t;\\mathbb{D})$ has expectation zero with respect to the marginal distribution conditioned on data, but it does not likely have expectation zero when given the entirety of $q_t$; and (ii) state-of-the-art diffusion models do not inherently minimize $\\lVert\\mathbb{E}_{q_t} s_\\theta^t \\rVert$. I believe those two points are quite separate but lines 188-191 present it as one singular point, which seems as if the paper treats the diffusion modeling as the gold standard of learning the scores, and that even the true score carries a bias in a finite-data setting. \n- I admit that the finite data bias can present a problem, but it is not what the calibration trick is for. Frankly speaking, the calibration trick does not manufacture new training data just because it is more calibrated, but only pushes the score estimate _towards_ the optimal score estimate attainable in a finite data regime, i.e., $\\nabla \\log q_t(x_t;\\mathbb{D})$. It is with this argument that I believe the calibration trick will attempt to modify the score estimate even when presented with the ground truth $\\nabla \\log q_t(x_t)$. Therefore, I believe the main point is not about dataset bias, but that common score matching objectives do not take into consideration the minimization of $\\lVert\\mathbb{E}_{q_t} s_\\theta^t \\rVert$.\n\nQUESTIONS:\nNone.\n\nLIMITATIONS:\nI believe that the authors can make a few improvements in its presentation of empirical results. I understand that page limit prohibits the addition of more content, but I believe that some plots deserve to be in the main body of text. \n- Figure 1 showcases the potential lack of calibration for pre-trained DPMs, but does not show the expectation of predicted noise _after_ calibration. I believe that one can show the effectiveness of calibration by comparing the 2 images and discovering the calibrated model has a much lower expected value of the predicted noise. \n- The paper could benefit from also presenting some generated images as it shows any improvements in the most straightforward way. Currently there is a figure in the appendix about how calibration \"reduce ambiguous generations\", but there are too many examples to see a measurable difference. I believe a smaller plot highlighting the said ambiguous generations deserves a spot in the main text.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces a general calibration technique for diffusion probabilistic models (DPMs). The authors derive a time-dependent calibration term that is independent of any particular input under different model parameterizations. This calibration term can be computed in advance and repeatedly used for sampling. The experimental results demonstrate the effectiveness of the proposed calibration method with a noticeable reduction of FIDs when taking 15-40 NFEs.\n\nSTRENGTHS:\nThe proposed calibration method in this paper is novel, theoretically sound, and practically useful in that it in principle can be applied to all kinds of DPMs to improve sampling with little computational overhead. The authors provide a performance analysis with varying numbers of samples for approximating the calibration term using the MC method. The FID results suggest that 20K of MC samples are sufficient to estimate the calibration term and reach the best quality. In this sense, the pre-sampling computation seems not to be too expensive. Overall, this approach appears to be general and easy to implement. Therefore, I believe this paper is significant and worth acceptance in NeurIPS.\n\nWEAKNESSES:\nAlthough the calibration term is not $x_t$-dependent, it depends on time ($t$) and the model parameters ($\\theta$). I am therefore concerned about the stability of the proposed approach. From Figure 1, we can basically confirm that the range of calibration terms drastically varies over different data sets. In this sense, if we apply the proposed approach to a new data set, there are at least three dynamic factors -- $t$, $\\theta$, and data distribution $q_0(x_0)$ that could affect the performance of this calibration method. In regard to this, I suggest the author conduct more validation experiments to prove the stability and consistency of the proposed method over different time steps, models, and datasets.\n\nQUESTIONS:\nWhat are the FID results of AFHQv2 64×64, FFHQ 64×64, and ImageNet 64×64? Following my concerns on stability, in the main paper, the authors state that they have conducted experiments on these datasets based on pre-trained models considering their top performance. However, I cannot find these numbers in the main paper and in the appendix. Why do you choose to only present CIFAR-10 and CelebA 64x64 in the main paper? I believe that an improvement on the ImageNet 64×64 is more convincing. I suggest the authors keep the FIDs of all these datasets in the main paper and compare them to the original DPMs.\n\nLIMITATIONS:\nThe impact of this paper may be limited by the lack of comparison against other existing methods. I tend to categorize this paper into research that improves pre-trained DPMs generally at inference time. Along this direction of research, there are several relevant works, which I believe the author could easily compare to, i.e., (not trainable) PNDM [1],  Analytic-DPM [2], and (trainable) BDDM [3].\n\n[1] Liu, Luping, et al. \"Pseudo Numerical Methods for Diffusion Models on Manifolds.\"\n[2] Bao, Fan, et al. \"Analytic-DPM: an Analytic Estimate of the Optimal Reverse Variance in Diffusion Probabilistic Models.\"\n[3] Lam, Max WY, et al. \"Bilateral Denoising Diffusion Models.\"", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents a simple way to calibrate an arbitrary pretrained diffusion probabilistic model (DPM), which can reduce the score matching loss and increase the lower bounds of model likelihood. The authors observe that the stochastic reverse process of data scores is a martingale, from which concentration bounds and the optional stopping theorem for data scores can be derived. The proposed calibration method is easy to follow and can be performed only once, resulting in models that can be used repeatedly for sampling. The premise is that DPMs are by default uncalibrated (which they show experimentally), and that calibration can result in improved generation. This again is showed experimentally using the FID metric.\n\n—-\nRaised score from 4 to 6 post-rebuttal. On the whole it seems like the method can have some positive impacts - mostly in terms of model likelihood (with subsequent downstream benefits), and sometimes in terms of the quality of generated images.\n\nSTRENGTHS:\n- clear and concise presentation of the proposed calibration method\n- empirical validation of the method on multiple datasets,\n- derivation of concentration bounds and the optional stopping theorem for data scores\n\nWEAKNESSES:\nThis biggest weakness is solely relying on model likelihood and the FID score for measuring generative performance. FID (Heusel et al., 2017) calculates the Wasserstein-2 (a.k.a Fréchet) distance between multivariate Gaussians fitted to the embedding space of the Inception-v3 network of generated and real image. A major drawback with FID is its high bias. The sample size to calculate FID has to be large enough (usually above 50K). Smaller sample sizes can lead to over-estimation of the actual FID. This can clearly bee seen in Table 3. \n\nIt's not a surprise that the model likelihood improves (since this is directly linked to calibration), but the link between model likelihood and generation quality is not at all clear.\n\nQUESTIONS:\nIn the supplementary material, some example generated images are given with/without calibration. I zoomed right in, but I struggled to see any difference between pairs of images - is there anything that demonstrates that calibrating improves matters?\n\nLIMITATIONS:\nYes, the authors have partially addressed the limitations in that they acknowledged that the model likelihood comes down but not necessarily FID, although they don't answer the question of whether it improves generation quality! Also there is a scaling issue with the method that is identified.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe paper makes an observation regarding the reverse process of diffusion probabilistic model, noting that the data score term  is a martingale with respect to this process. A key contribution of the paper is a theorem to this effect and the associated proof. Leveraging this observation, the authors propose a calibration technique: one can calibrate a pretrained diffusion model at any time step by subtracting its expectation. Experimental results in the paper demonstrate that the calibrated score model achieves lower values of score matching objectives. Furthermore, the paper provides evidence that the calibrated score model yields higher evidence lower bounds. Lastly, the paper explains that similar conclusions hold true for the conditional score model.\n\nSTRENGTHS:\nS1. The paper makes a novel and significant observation concerning the martingale nature of the data score term in probabilistic diffusion models with respect to the reverse process. \n\nS2. The paper is clearly written, well-organized, and provides a key theorem and proof that are presented in a readily-followed fashion. \n\nS3.  The innovative technique for calibration is soundly based on theoretically-derived principles, is relatively simple to compute, and achieves an experimental performance improvement. The method is extended to the conditional setting. \n\nS4. The paper provides visualizations of the expected predicted noises and associated discussion that helps the reader understand the inductive bias. The additional experimental analysis is a welcome addition (sensitivity to the number of training samples, performance using generated samples, dynamic recording performance).\n\nWEAKNESSES:\nW1. Although the proposed method achieves an improvement in terms of model likelihood, the experiments are less convincing that there is a meaningful practical improvement in terms of generated samples. There is an improvement in FID, but the sample images are presented in the appendix in such a way that it is almost impossible to discern a difference between the calibrated and uncalibrated models.\n\nW2. The reported experiments only assess sample quality using FID. Multiple papers have demonstrated how this metric can be misleading in some circumstances and have proposed alternatives, e.g., precision and recall metrics, that can be used in conjunction with FID to provide a clearer and more complete assessment of the capabilities of a generative model. \n\nW3. There is very little discussion of computational and memory requirements for the calibration. The paper could benefit from a much clearer discussion of the costs that are incurred in order to obtain the calibration benefit.\n\nQUESTIONS:\nQ1. Can the authors provide a clearer commentary about the claimed subjective quality improvement. The generated images in Appendix C are extremely small. There is almost no discussion beyond “Our calibration could help to reduce ambiguous generations” – this is almost impossible for a reader to verify with the way the images are presented and it is not clear exactly what is meant. \n\nQ2. Could the authors comment on how the method performs for other performance metrics for generative models?\n\nQ3. What is the computational and memory cost (particulary in comparison to the original model)? i.e., does it increase the computational overhead by 30 percent? Is the memory cost an additional 20 percent?\n\nLIMITATIONS:\nThe paper provides a very brief discussion of the limitations. This is definitely useful, and the authors acknowledge some of the key limitations. On the other hand, it would strengthen the paper if the supplementary material contained a more in-depth discussion. In particular, additional discussion concerning overhead and whether the proposed method translates to genuine practical benefits would be welcome. The section could discuss the challenge of evaluating generative models and suggest potential research avenues fhat might help establish whether the calibration improvement translates to more applied settings.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-08"}