CARD: Classification and Regression Diffusion Models
Abstract
Learning the distribution of a continuous or categorical response variable y given its covariates x is a fundamental problem in statistics and machine learning.
Deep neural network-based supervised learning algorithms have made great progress in predicting the mean of y given x , but they are often criticized for their ability to accurately capture the uncertainty of their predictions.
In this paper, we introduce classification and regression diffusion (CARD) models, which combine a denoising diffusion-based conditional generative model and a pre-trained conditional mean estimator, to accurately predict the distribution of y given x .
We demonstrate the outstanding ability of CARD in conditional distribution prediction with both toy examples and real-world datasets, the experimental results on which show that
CARD in general outperforms state-of-the-art methods, including Bayesian neural network-based ones that are designed for uncertainty estimation, especially when the conditional distribution of y given x is multi-modal.
In addition, we utilize the stochastic nature of the generative model outputs to obtain a finer granularity in model confidence assessment at the instance level for classification tasks.
Our implementation is publicly available at https://github.com/XzwHan/CARD.
Introduction
A fundamental problem in statistics and machine learning is to predict the response variable y given a set of covariates x .
Generally speaking, y is a continuous variable for regression analysis and a categorical variable for classification.
Denote f ( x ) ∈ R C as a deterministic function that transforms x into a C dimensional output.
Denote f c ( x ) as the c -th dimension of f ( x ) .
Existing methods typically assume an additive noise model: for regression analysis with y ∈ R C , one often assumes y =
f ( x ) + ϵ , ϵ ∼ N (0 , Σ ) , while for classification with y ∈ { 1 , . .
, C } , one often assumes y = arg max (cid:0) f 1 ( x ) + ϵ 1 , . . .
, f C ( x ) + ϵ C (cid:1) , where ϵ c iid ∼ EV 1 (0 , 1) , a standard type-1 extreme value distribution.
Thus we have the expected value of y given x as E
[ y | x ] = f ( x ) in regression and P ( y = c | x ) =
E [ y = c | x ] = softmax c (cid:0) f ( x ) (cid:1) =
exp( f c ( x )) (cid:80) Cc ′
=
1 exp( f c ′ ( x )) in classification.
These additive-noise models are primarily focusing on accurately estimating the conditional mean
E [ y | x ] , while paying less attention to whether the noise distribution can accurately capture the uncertainty of y given x .
For this reason, they may not work well if the distribution of y given x clearly deviates from the additive-noise assumption.
For example, if p ( y | x ) is multi-modal, which commonly happens when there are missing categorical covariates in x , then E [ y | x ] may not be close to any possible true values of y given that specific x .
More specifically, consider a person whose weight, height, blood pressure, and age are known but gender is unknown, then the testosterone or estrogen level of this person is likely to follow a bi-modal distribution and the chance ∗ Equal contribution.
of developing breast cancer is also likely to follow a bi-modal distribution.
Therefore, these widely used additive-noise models, which use a deterministic function f ( x ) to characterize the conditional mean of y , are inherently restrictive in their ability for uncertainty estimation.
In this paper, our goal is to accurately recover the full distribution of y conditioning on x given a set of N training data points, denoted as D = { ( x i , y i ) } 1 ,N .
To realize this goal, we consider the diffusion-based (a.k.a. score-based) generative models (Sohl-Dickstein et al., 2015; Song and Ermon, 2019;
Ho et al., 2020; Song and Ermon, 2020; Song et al., 2021c) and inject covariate-dependence into both the forward and reverse diffusion chains.
Our method can model the conditional distribution of both continuous and categorical y variables, and the algorithms developed under this method will be collectively referred to as C lassification A nd R egression D iffusion (CARD) models.
Diffusion-based generative models have received significant recent attention due to not only their ability to generate high-dimensional data, such as high-resolution photo-realistic images, but also their training stability.
They can be understood from the perspective of score matching (Hyvärinen and Dayan, 2005; Vincent, 2011) and Langevin dynamics (Neal, 2011; Welling and Teh, 2011), as pioneered by Song and Ermon (2019).
They can also be understood from the perspective of diffusion probabilistic models (Sohl-Dickstein et al., 2015; Ho et al., 2020), which first define a forward diffusion to transform the data into noise and then a reverse diffusion to regenerate the data from noise.
These previous methods mainly focus on unconditional generative modeling.
While there exist guided-diffusion models (Song and Ermon, 2019; Song et al., 2021c; Dhariwal and Nichol, 2021;
Nichol et al., 2022; Ramesh et al., 2022) that target on generating high-resolution photo-realistic images that match the semantic meanings or content of the label, text, or corrupted-images, we focus on studying diffusion-based conditional generative modeling at a more fundamental level.
In particular, our goal is to thoroughly investigate whether CARD can help accurately recover p ( y | x , D ) , the predictive distribution of y given x after observing data D
= { ( x i , y i ) } i =1 ,N .
In other words, our focus is on regression analysis of continuous or categorical response variables given their corresponding covariates.
We summarize our main contributions as follows: 1) We show CARD, which injects covariatedependence and a pre-trained conditional mean estimator into both the forward and reverse diffusion chains to construct a denoising diffusion probabilistic model, provides an accurate estimation of p ( y | x , D ) .
We provide a new metric to better evaluate how well a regression model captures the full distribution p ( y | x , D ) .
3) Experiments on standard benchmarks for regression analysis show that CARD achieves state-of-the-art results, using both existing metrics and the new one. 4)
For classification tasks, we push the assessment of model confidence in its predictions towards the level of individual instances, a finer granularity than the previous methods.
Methods and Algorithms for CARD
Given the ground-truth response variable y 0 and its covariates x , and assuming a sequence of intermediate predictions y 1: T made by the diffusion model, the goal of supervised learning is to learn a model such that the log-likelihood is maximized by optimizing the following ELBO:
[Equation]
where q ( y 1: T | y 0 , x ) is called the forward process or diffusion process in the concept of diffusion models (Sohl-Dickstein et al., 2015; Ho et al., 2020).
Denote D KL ( q || p ) as the Kullback–Leibler (KL) divergence from distribution p to distribution q .
The above objective can be rewritten as
[Equation]
Here we follow the convention to assume L T does not depend on any parameter and it will be close to zero by carefully diffusing the observed response variable y 0 towards a pre-assumed distribution p ( y T | x ) .
The remaining terms will make the model p θ ( y t − 1 | y t , x ) approximate the corresponding tractable ground-truth denoising transition step q ( y t − 1 | y t , y 0 , x ) for all timesteps.
Different from the vanilla diffusion models, we assume the endpoint of our diffusion process to be
[Equation]
) where f ϕ ( x ) is the prior knowledge of the relation between x and y 0 , e.g. , a network pre-trained with D to approximate E [ y | x ] , or 0 if we assume the relation is unknown.
With a diffusion schedule { β t } t =1: T ∈ (0 , 1) T , we specify the forward process conditional distributions in a similar fashion as
Pandey et al.
(2022), but
for all timesteps including t = 1 :
[Equation]
which admits a closed-form sampling distribution with an arbitrary timestep t :
[Equation]
where α t := 1 − β t and ¯ α t := (cid:81) t α t .
Note that the mean term in Eq.
(7) can be viewed as an interpolation between true data y 0 and the predicted conditional expectation f ϕ ( x ) , which gradually changes from the former to the latter throughout the forward process.
Such formulation corresponds to a tractable forward process posterior:
[Equation]
where
[Equation]
We provide the derivation in Appendix A.1.
The labels under the terms are used in Algorithm 2.
2.1 CARD for Regression
For regression problems, the goal of the reverse diffusion process is to gradually recover the distribution of the noise term, the aleatoric or local uncertainty inherent in the observations (Kendall and
Gal, 2017; Wang and Zhou, 2020), enabling us to generate samples that match the true conditional p ( y | x ) .
Following the reparameterization introduced by denoising diffusion probabilistic models (DDPM)
(Ho et al., 2020), we construct ϵ θ (cid:0) x , y t , f ϕ ( x ) , t (cid:1) , which is a function approximator parameterized by a deep neural network that predicts the forward diffusion noise ϵ sampled for y t .
The training and inference procedure can be carried out in a standard DDPM manner.
Draw t ∼ Uniform ( { 1 . . .
T } ) 5:
Draw ϵ ∼ N ( 0 , I ) 6:
Compute noise estimation loss
[Equation]
Take numerical optimization step on: ∇
[Equation]
L ϵ 8: until Convergence
1: y T ∼ N ( f ϕ ( x ) , I ) 2: for t =
T to 1 do 3:
Draw z ∼ N ( 0 , I ) if t >4:
Calculate reparameterized
[Equation]
Let y t − 1 = γ
ˆ y 0 + γ 1 y t + γ 2 f
ϕ
x ) + (cid:113) ˜
β t z if t > 1 , else set y t −
=
ˆ y6: end for 7: return y2.2 CARD for Classification
We formulate the classification tasks in a similar fashion as in Section 2.1, where we:
Replace the continuous response variable with a one-hot encoded label vector for y 0 ; 2.
Replace the mean estimator with a pre-trained classifier that outputs softmax probabilities of the class labels for f ϕ ( x ) .
This construction no longer assumes y 0 to be drawn from a categorical distribution, but instead treats each one-hot label as a class prototype, i.e. , we assume a continuous data and state space, which enables us to keep the Gaussian diffusion model framework.
The sampling procedure would output reconstructed y 0 in the range of real numbers for each dimension, instead of a vector in the probability simplex.
Denoting C as the number of classes and 1 C as a C -dimensional vector of 1 s, we convert such output to a probability vector in a softmax form of a temperature-weighted Brier score (Brier, 1950), which computes the squared error between the prediction and 1 C .
Mathematically, the probability of predicting the k th class and the final point prediction ˆ y can be expressed as
[Equation]
where τ > 0 is the temperature parameter, and ( y 0 − 1 C ) 2 k indicates the k th dimension of the vector of element-wise square error between y 0 and 1 C , i.e. , ( y 0 − 1 C ) 2 k = ∥
y 0 k − 1 ∥ 2 .
Intuitively, this construction would assign the class whose raw output in the sampled y 0 is closest to the true class, encoded by the value of 1 in the one-hot label, with the highest probability.
Conditional on the same covariates x , the stochasticity of the generative model would give us a different class prototype reconstruction after each reverse process sampling, which enables us to construct predicted probability intervals for all class labels.
Such stochastic reconstruction is in a similar fashion as DALL-E 2 (Ramesh et al., 2022) that applies a diffusion prior to reconstruct the image embedding by conditioning on the text embedding during the reverse diffusion process, which is a key step in the diversity of generated images.
Related Work
Under the supervised learning settings, to model the conditional distribution p ( y | x ) besides just the conditional mean E [ y | x ] through deep neural networks, existing works have been focusing on quantifying predictive uncertainty, and several lines of work have been proposed.
Bayesian neural networks (BNNs) model such uncertainty by assuming distributions over network parameters, capturing the plausibility of the model given the data (Blundell et al., 2015; Hernández-Lobato and
Adams, 2015; Gal and Ghahramani, 2016; Kingma et al., 2015; Tomczak et al., 2021).
Kendall and
Gal (2017) also model the uncertainties in the model outputs besides model parameters, by including the additive noise term as part of the neural network output.
Meanwhile, ensemble-based methods (Lakshminarayanan et al., 2017; Liu et al., 2022) have been proposed to model predictive uncertainty by combining multiple neural networks with stochastic outputs.
Furthermore, the Neural Processes
Family (Garnelo et al., 2018b,a; Kim et al., 2019; Gordon et al., 2020) has introduced a series of models that capture predictive uncertainty in an out-of-distribution fashion, particularly designed for few-shot learning settings.
These above mentioned models have all assumed a parametric form in p ( y | x ) , namely Gaussian distribution, or a mixture of Gaussians, and optimize the network parameters based on a Gaussian negative log-likelihood objective function.
Deep generative models, on the other hand, have been known for modeling implicit distributions without parametric distributional assumptions, but very few works have been proposed to utilize such feature to tackle regression tasks.
GAN-based models are introduced by Zhou et al.
(2021) and Liu et al.
(2021) for conditional density estimation and predictive uncertainty quantification.
For classification tasks, on the other hand, generative classifiers (Revow et al., 1996; Fetaya et al., 2020; Ardizzone et al., 2020; Mackowiak et al., 2021) is a class of models that also perform classification with generative models; among them, Zimmermann et al.
(2021) propose score-based generative classifiers to tackle classification tasks with score-based generative models (Song et al., 2021b,c).
They model p ( x | y ) and predict the label with the largest conditional likelihood of x , while CARD models p ( y | x ) instead.
In recent years, the class of diffusion-based (or score-based) deep generative models has demonstrated its outstanding performance in modeling high-dimensional multi-modal distributions (Ho et al., 2020;
Song et al., 2021a; Kawar et al., 2022; Xiao et al., 2022; Dhariwal and Nichol, 2021; Song and Ermon, 2019, 2020), with most work focusing on Gaussian diffusion processes operating in continuous state spaces.
Hoogeboom et al.
(2021) introduce extensions of diffusion models for categorical data, and Austin et al.
(2021) have proposed diffusion models for discrete data as a generalization of the multinomial diffusion models, which could provide an alternative way of performing classification with diffusion-based models.
Experiments
For the hyperparameters of CARD in both regression and classification tasks, we set the number of timesteps as T = 1000 , a linear noise schedule with β 1 = 10 − 4 and β T = 0 .
02 , same as Ho et al.
We provide a more detailed walk-through of the experimental setup, including training and network architecture, in Appendix A.8.
4.1 Regression
Putting aside its statistical interpretation, the word regress indicates a direction opposite to progress , suggesting a less developed state.
Such semantics in fact translates well into the statistical domain, in the sense that traditional regression analysis methods often only focus on estimating E ( y | x ) , while leaving out all remaining details about p ( y | x ) .
In recent years, Bayesian neural networks (BNNs) have emerged as a class of models that aims at estimating the uncertainty (Hernández-Lobato and
Adams, 2015; Gal and Ghahramani, 2016; Lakshminarayanan et al., 2017; Tomczak et al., 2021), providing a more complete picture of p ( y | x ) .
The metric that they use to quantify uncertainty estimation, negative log-likelihood (NLL), is computed with a Gaussian density, implying their assumption such that the conditional distributions p ( y | x = x ) for all x are Gaussian.
However, this assumption is very difficult to verify for real-world datasets: the covariates can be arbitrarily high-dimensional, making the feature space increasingly sparse with respect to the number of collected observations.
To accommodate the need for uncertainty estimation without imposing such restriction for the parametric form of p ( y | x ) , we apply the following two metrics, both of which are designed to empirically evaluate the level of similarity between the learned and the true conditional distributions:
Prediction Interval Coverage Probability (PICP); 2.
Quantile Interval Coverage Error (QICE).
PICP has been described in Yao et al.
(2019), whereas QICE is a new metric proposed by us.
We describe both of them in what follows.
4.1.1 PICP and QICE
The PICP is computed as
[Equation]
where ˆ y low n and ˆ y high n represent the low and high percentiles, respectively, of our choice for the predicted y outputs given the same x input.
This metric measures the proportion of true observations that fall in the percentile range of the generated y samples given each x input.
Intuitively, when the learned distribution represents the true distribution well, this measurement should be close to the difference between the selected low and high percentiles.
In this paper, we choose the 2 .
5 th and 97 .
5 th percentile, thus an ideal PICP value for the learned model should be 95% .
Meanwhile, there is a caveat for this metric: for example, imagine a situation where the 2 .
5 th to 97 .
5 th percentile of the learned distribution happens to cover the data between the 1 st and 96 th percentiles from the true distribution.
Given enough samples, we shall still obtain a PICP value close to 95% , but clearly there is a mismatch between the learned distribution and the true one.
Based on such reasoning, we propose a new empirical metric QICE, which by design can be viewed as PICP with finer granularity, and without uncovered quantile ranges.
To compute QICE, we first generate enough y samples given each x , and divide them into M bins with roughly equal sizes.
We would obtain the corresponding quantile values at each boundary.
In this paper, we set M = 10 , and obtain the following 10 quantile intervals (QIs) of the generated y samples: below the 10 th percentile, between the 10 th and 20 th percentiles, . . .
, between the 80 th and 90 th percentiles, and above the 90 th percentile.
Optimally, when the learned conditional distribution is identical to the true one, given enough samples from both learned and true distribution we shall observe about 10% of true data falling into each of these 10 QIs.
We define QICE to be the mean absolute error between the proportion of true data contained by each
QI and the optimal proportion, which is 1 /M for all intervals:
[Equation]
where r m = 1 N
N (cid:88)
[Equation]
Intuitively, under optimal scenario with enough samples, we shall obtain a QICE value of 0 .
Note that each r m is indeed the PICP for the corresponding QI with boundaries at ˆ y low m n and ˆ y high m n .
Since the true y for each x is guaranteed to fall into one of these QIs, we are thus able to overcome the mismatch issue described in the above example for PICP: fewer true instances falling into one QI would result in more instances captured by another QI, thus increasing the absolute error for both QIs.
QICE is similar to NLL in the sense that it also utilizes the summary statistics of the samples from the learned distribution conditional on each new x to empirically evaluate how well the model fits the true data.
Meanwhile, it does not assume any parametric form on the conditional distribution, making it a much more generalizable metric to measure the level of distributional match between the learned and the underlying true conditional distributions, especially when the true conditional distribution is known to be multi-modal.
We will demonstrate this point through the regression toy examples.
4.1.2 Toy Examples
To demonstrate the effectiveness of CARD in regression tasks for not only learning the conditional mean E ( y | x ) , but also recreating the ground truth data generating mechanism, we first apply CARD on 8 toy examples, whose data generating functions are designed to possess different statistical characteristics:
some have a uni-modal symmetric distribution for their error term (linear regression, quadratic regression, sinusoidal regression), others have heteroscedasticity (log-log linear regression, log-log cubic regression) or multi-modality (inverse sinusoidal regression, 8 Gaussians, full circle).
We show that the trained CARD models can generate samples that are visually indistinguishable from the true response variables of the new covariates, as well as quantitatively match the true distribution in terms of some summary statistics.
We present the scatter plots of both true and generated data for all 8 tasks in Figure 1.
For tasks with uni-modal conditional distribution, we fill the region between the 2 .
5 th and 97 .
5 th percentile of the generated y ’s.
We observe that within each task, the generated samples blend remarkably well with the true test instances, suggesting the capability of reconstructing the underlying data generation mechanism by CARD.
A more detailed description of the toy examples, including more quantitative analyses, is presented in Appendix A.13.
4.1.3 UCI Regression Tasks
We continue to investigate our model through experiments on real-world datasets.
We adopt the same set of 10 UCI regression benchmark datasets (Dua and Graff, 2017) as well as the experimental protocol proposed by Hernández-Lobato and Adams (2015) and followed by Gal and Ghahramani (2016) and Lakshminarayanan et al.
The dataset information is provided in Table 14.
We apply multiple train-test splits with 90% / 10% ratio in the same way as Hernández-Lobato and
Adams (2015) ( 20 folds for all datasets except 5 for Protein and 1 for Year), and report the metrics by their mean and standard deviation across all splits.
We compare our method to all aforementioned
BNN frameworks: PBP, MC Dropout, and Deep Ensembles, as well as another deep generative model that estimates a conditional distribution sampler, GCDS (Zhou et al., 2021).
We note that
GCDS is related to a concurrent work of Yang et al.
(2022), who share a comparable idea but use it in a different application.
Following the same paradigm of BNN model assessment, we evaluate the accuracy and predictive uncertainty estimation of CARD by reporting RMSE and NLL.
Furthermore, we also report QICE for all methods to evaluate distributional matching.
Since this new metric was not applied in previous methods, we re-ran the experiments for all BNNs and obtained comparable or slightly better results in terms of other commonly used metrics reported in their literature.
Further details about the experimental setup for these models can be found in Appendix A.9.
The experiment results with corresponding metrics are shown in Tables 1, 2, and 3, with the number of times that each model achieves the best corresponding metric reported in the last row.
We observe that CARD outperforms existing methods, often by a considerable margin (especially on larger datasets), in all metrics for most of the datasets, and is competitive with the best method for the remaining ones: we obtain state-of-the-art results in 9 out of 10 datasets in terms of RMSE, 8 out of 10 for NLL, and 5 out of 10 for QICE.
It is worth noting that although we do not explicitly optimize our model by MSE or by NLL, we still obtain better results than models trained with these objectives.
4.2 Classification
Similar to Lakshminarayanan et al.
(2017), our motivation for classification is not to achieve state-ofthe-art performance in terms of mean accuracy on the benchmark datasets, which is strongly related to network architecture design.
Our goal is two-fold:
We aim to solve classification problems via a generative model, emphasizing its capability to improve the performance of a base classifier with deterministic outputs in terms of accuracy; 2.
We intend to provide an alternative sense of uncertainty, by introducing the idea of model confidence at the instance level, i.e. , how sure the model is about each of its predictions, through the stochasticity of outputs from a generative model.
As another type of supervised learning problems, classification is different from regression mainly for the response variable being discrete class labels instead of continuous values.
The conventional operation is to cast the classifier output as a point estimate, with a value between 0 and 1 .
Such
[Table] [Table]
[Table]
design is intended for prediction interpretability: since humans already have a cognitive intuition for probabilities (Cosmides and Tooby, 1996)
[Table]
the output from a classification model is intended to convey a sense of likelihood for a particular class label.
In other words, the predicted probability should reflect its confidence,
i
[Table]
e. , a level of certainty, in predicting such a label.
Guo et al.
(2017) provide the following example of a good classifier, whose output aligns with human intuition for probabilities: if the model outputs a probability prediction of 0 .
8 , we hope it indicates that the model is 80% sure that its prediction is correct; given 100 predictions of 0 . 8 , one shall expect roughly 80 of them are correct.
In that sense, a good classification algorithm not only can predict the correct label, but also can reflect the true correctness likelihood through its probability predictions, i.e. , providing calibrated confidence (Guo et al., 2017).
To evaluate the level of miscalibration by a model, metrics like
Expected Calibration Error (ECE) and Maximum Calibration Error (MCE) (Naeini et al., 2015) have been adopted in recent literature (Kristiadi et al., 2022; Rudner et al., 2021) for image classification tasks, and calibration methods like Platt scaling and isotonic regression have been developed to improve such alignment (Guo et al., 2017).
Note that these methods are all based on point estimate predictions by the classifier.
Furthermore, these alignment metrics can only be computed at a subgroup level in practice, instead of at the instance level.
In other words, one may not be able to make the claim with the existing classification framework such that given a particular test instance , how confident the classifier is in its prediction to be correct.
We discuss our analysis in ECE with more details in Appendix A.16, which may help justify our motivation in introducing an alternative way to measure model confidence at the level of individual test instances in Section 4.2.1.
4.2.1 Predict with Instance Level Model Confidence via Generative Models
We propose the following framework to assess model confidence for its predictions at the instance level : for each test instance, we first sample N class prototype reconstructions by CARD through the classification version of Algorithm 2, and then perform the following computations:
We directly calculate the prediction interval width (PIW) between the 2 .
5 th and 97 .
5 th percentiles of the N reconstructed values for all classes,
i
e. , with C different classes in total, we would obtain C PIWs for each instance; 2.
We then convert the samples into probability space with Eq.
(10), and apply paired twosample t -test as an uncertainty estimation method proposed in Fan et al.
(2021): we obtain the most and second most predicted classes for each instance, and test whether the difference in their mean predicted probability is statistically significant.
This framework would require the classifier to not produce the exact same output each time, since the goal is to construct prediction intervals for each of the class labels.
Therefore, the class of generative models is a preferable modeling choice due to its ability to produce stochastic outputs, instead of just a point estimate by traditional classifiers.
In practice, we view each one-hot label as a class prototype in real continuous space (introduced in Section 2.2), and we use a generative model to reconstruct this prototype in a stochastic fashion.
The intuition is that if the classifier is sure about the class that a particular instance belongs to, it would precisely reconstruct the original prototype vector without much uncertainty; otherwise, different class prototype reconstructions of the same test instance tend to have more variations: under the context of denoising diffusion models, given different samples from the prior distribution at timestep T , the label reconstructions would appear rather different from each other.
4.2.2 Classification with Model Confidence on CIFAR-10 Dataset
We demonstrate our experimental results on the CIFAR-10 dataset.
We first contextualize the performance of CARD in conventional metrics including accuracy and NLL with other BNNs in ResNet-18 architecture in Table 4.
The metrics of other methods were reported in Tomczak et al.
(2021), a recent work in BNNs that proposes tighter ELBOs to improve variational inference performance and prior hyperparameter optimization.
Following the recipe in Section 2.2, we first pre-train a deterministic classifier with the same ResNet-18 architecture, and achieve a test accuracy of 90 .
39% , with which we proceed to train CARD.
We then obtain our instance prediction through majority vote, i.e. , the most predicted class label among its N samples for each image input, and achieve an improved test accuracy with a mean of 90 .
93% across 10 runs, showing its ability to improve test accuracy from the base classifier.
Our NLL result is competitive among the best ones, even though the model is not optimized with a cross-entropy objective function, as we assume the class labels to be in the real continuous space.
[Table]
We now present the results from one model run with the proposed framework in Section 4.2.1 for evaluating the instance-level prediction confidence.
After obtaining the PIW and paired two-sample t -test ( α = 0 . 05 ) result from each test instance, we first split the test instances into two groups by the correctness of majority-vote predictions, then we obtain only the PIW corresponding to the true class for each instance, and compute the mean PIW of the true class within each group.
In addition, we split the test instances by t -test rejection status, and compute the mean accuracy in each group.
We report the results from these two grouping procedures in Table 5, where the metrics are computed across all test instances and at the level of each true class label.
[Table]
We observe from Table 5 that under the scope of the entire test set
[Table]
the mean PIW of the true class label among the correct predictions is narrower than that of the incorrect predictions by an order of magnitude, indicating that when CARD is making correct predictions, its class label reconstructions have much smaller variations.
We may interpret such results as that CARD can reveal what it does not know through the relativity in reconstruction variations.
Furthermore, when comparing the mean
PIWs across different classes, we observe that the class with a higher prediction accuracy tends to have a sharper contrast in true label PIW between correct and incorrect predictions; additionally, the PIW values of both correct and incorrect predictions tend to be larger in a less accurate class.
Meanwhile, it is worth noting that if we predict the class label by the one with the narrowest PIW for each instance, we can already obtain a test accuracy of 87 .
84% , suggesting a strong correlation between the prediction correctness and instance-level model confidence (in terms of label reconstruction variability).
Moreover, we observe that the accuracy of test instances rejected by the t -test is much higher than that of the not-rejected ones, both across the entire test set and within each class.
We point out that these metrics can reflect how sure CARD is about the correctness of its predictions, and can thus be used as an important indicator of whether the model prediction of each instance can be trusted or not.
Therefore, it has the potential to be further applied in the human-machine collaboration domain (Madras et al., 2018;
Raghu et al., 2019; Wilder et al., 2020; Gao et al., 2021), such that one can apply such uncertainty measurement to decide if we can directly accept the model prediction, or we need to allocate the instance to humans for further evaluation.
Conclusion
In this paper, we propose Classification And Regression Diffusion (CARD) models, a class of conditional generative models that approaches supervised learning problems from a conditional generation perspective.
Without training with objectives directly related to the evaluation metrics, we achieve state-of-the-art results on benchmark regression tasks.
Furthermore, CARD exhibits a strong ability to represent the conditional distribution with multiple density modes.
We also propose a new metric Quantile Interval Coverage Error (QICE), which can be viewed as a generalized version of negative log-likelihood in evaluating how well the model fits the data.
Lastly, we introduce a framework to evaluate prediction uncertainty at the instance level for classification tasks.
Acknowledgments
The authors acknowledge the support of NSF IIS 1812699 and 2212418, and the Texas Advanced
Computing Center (TACC) for providing HPC resources that have contributed to the research results reported within this paper.
A Derivations and Additional Experiment Results A.1 Derivations
Derivation for Forward Process Posteriors:
In this section, we derive the mean and variance of the forward process posteriors q ( y t − 1 | y t , y 0 , x ) in Eq.
(9), which are tractable when conditioned on y 0 :
[Equation]
where
[Equation]
and we have the posterior variance
[Equation]
Meanwhile, the following coefficients of the terms in the posterior mean through dividing each coefficient in 2 by 1 :
[Equation]
and
[Equation]
which together give us the posterior mean
[Equation]
Derivation for
Forward Process Sampling
Distribution with Arbitrary Timesteps: For completeness, we include the derivation for the parameters of the forward diffusion process sampling distribution with arbitrary t steps.
The expectation term is based on Eqs.
(36) – (38) in Pandey et al.
From Eq.
(7), we have that for all t = 1 , . . .
, T ,
[Equation]
where ϵ ∼
[Equation] [Equation]
Taking expectation of both sides, we have
[Equation]
i =
[Equation]
Meanwhile, since the addition of two independent Gaussians with different variances, N ( 0 , σ 2 a I ) and N ( 0 , σ 2 b I ) , is distributed as N ( 0 , ( σ 2 a + σ 2 b ) I ) , we can derive the variance term accordingly,
[Equation]
A.2 More In-Depth Discussion on Several Related Works
In this section, we discuss the relations between CARD and several existing works, which are briefly addressed in Section 3, in more depth.
A.2.1 Comparing CARD with the Neural Processes Family
In short, CARD models p ( y | x , D in ) , while the Neural Processes Family (NPF) (Garnelo et al., 2018b,a; Kim et al., 2019; Gordon et al., 2020) models p ( y | x , D out ) , where D in and D out represents in-distribution dataset and out-of-distribution dataset, respectively.
Although both classes of methods can be expressed as modeling p ( y | x , D ) , CARD assumes such ( x , y ) comes from the same data-generating mechanism as the set D , while NPF assumes ( x , y ) to be not from the same distribution as D .
While CARD fits in the traditional supervised learning setting for in-distribution generalization, NPF is specifically suited for few-shot learning scenarios, where a good model would capture enough pattern from previously seen datasets so that it can generalize well with very limited samples from the new dataset.
Furthermore, both classes of models are capable of generating stochastic outputs, where CARD aims to capture aleatoric uncertainty, which is intrinsic to the data (thus cannot be reduced), while NPF can express epistemic uncertainty as it proposes more diverse functional forms at regions where data is sparse (and such uncertainty would reduce when more data is given).
In terms of the conditioning of
D , the information of D is amortized into the network ϵ θ for CARD, while it is included as an explicit representation in the network of NPF that outputs the distribution parameters for p ( y | x ) .
It is also worth pointing out that CARD does not assume a parametric distributional form for p ( y | x , D ) , while
NPF assumes a Gaussian distribution, and designs the objective function with such assumption.
The concept and comparison between epistemic and aleatoric uncertainty is more thoroughly discussed by Kendall and Gal (2017), in which we quote, “Out-of-data examples, which can be identified with epistemic uncertainty, cannot be identified with aleatoric uncertainty alone.”
We acknowledge that modeling OOD uncertainty is an important topic for regression tasks; however, we design our model to focus on modeling aleatoric uncertainty in this paper.
We plan to explore CARD’s ability in extrapolation as part of our future work.
A.2.2 Comparing CARD with Discrete Diffusion Models
To construct our framework for classification, we assume the class labels (in terms of one-hot vectors) are from real continuous spaces instead of discrete ones.
This assumption enables us to model the forward diffusion process and prior distribution at timestep T with Gaussian distributions, thus all derivations under the regression setting with analytical computation of KL terms, as well as the corresponding algorithms, generalize naturally into the classification settings.
The code for training and inference is exactly the same.
Discrete Denoising Diffusion Probabilistic Models (D3PMs) (Austin et al., 2021) fit conventional perception in classification tasks naturally by keeping the assumption of a categorical distribution.
Therefore, the corresponding evaluation metrics like NLL can directly translate into such a framework — we believe that by adopting the discrete space assumption, a better NLL metric can be achieved.
Meanwhile, it would require a lot more changes to be made from our framework for regression tasks, including the choice of the transition matrix, the incorporation of x into the diffusion processes, as well as the addition of the auxiliary loss into the objective function — all of the above are classification-task-specific settings, and cannot be adopted with the existing framework for regression tasks.
Besides the intention for consistency and generalizability across the two types of supervised learning tasks, we found that our current construction gives reasonable results to access model prediction confidence at the instance level — by directly using the prediction intervals obtained in the raw continuous space, i.e. , before adopting the softmax function for conversion to probability space, we obtain the sharp contrast in true label PIW between correct and incorrect predictions, and can already achieve high accuracy by merely predicting the label with the narrowest PIW for each instance.
However, after converting the reconstructed labels to the probability space, the true label PIW contrast is reduced drastically, and the prediction accuracy by the narrowest PIW is similar to a random guess.
To recap, if achieving the best NLL and ECE for classification is the goal, then we think discrete diffusion models like Austin et al.
(2021) could be excellent choices due to their use of the crossentropy loss that is directed related to NLL and ECE; however, if the main goal is to access the prediction confidence at the instance level, the proposed CARD framework works well, and it would be interesting to make a head-to-head comparison with discrete diffusion-based classification models that yet need to be developed.
A.2.3 Comparing CARD with Kendall and Gal (2017)
Kendall and Gal (2017) address BNN as an important class of methods for modeling uncertainty.
CARD is similar to BNNs in providing stochastic outputs.
However, BNNs deliver such stochasticity by modeling epistemic uncertainty, the uncertainty over network parameters W (by placing a prior distribution over W ) — this type of uncertainty is a property of the model .
On the other hand,
CARD does not model epistemic uncertainty, as it applies a deterministic deep neural network as its functional form; it is designed to model aleatoric uncertainty instead, which is a property intrinsic to the data .
In Eq.
2 of Kendall and Gal (2017), such aleatoric uncertainty is captured by the last term as σ 2 , which is a constant with respect to the network parameters θ for the variational distribution of model parameter W , thus ignored during the optimization of θ .
The new method proposed in
Kendall and Gal (2017) aims to model the aleatoric uncertainty by making σ 2 as part of the BNN output (Eq. 7); however, note that it still explicitly assumes p ( y | x ) to be a Gaussian distribution, as the objective function is the negative Gaussian log-likelihood, thus its effectiveness in capturing the actual aleatoric uncertainty depends on the validity of such parametric assumption for p ( y | x ) .
A.2.4 Comparing CARD with Score-Based Generative Classifiers
From a naming perspective, it might be easy to confuse CARD for classification as a type of generative classifiers , as it utilizes a generative model to conduct classification tasks.
However, they are two different types of generative models, as generative classifiers model the conditional distribution p ( x | y ) , while CARD models a different conditional distribution, i.e. , p ( y | x ) .
In fact,
CARD shall be categorized as a type of discriminative classifier, by the definition in Zimmermann et al.
Note that although both types of classifiers under image-based tasks would report NLL as one evaluation metric, they are also different, since the NLL for generative classifiers is evaluated in the space transformed from the logit space of x , while the NLL for discriminative classifiers is computed in the space of y as the cross-entropy between the true label and the predicted probability.
A.3 Classification on FashionMNIST Dataset
We perform classification on FashionMNIST dataset with CARD, and present the results in a similar fashion as Section 4.2.2.
We first contextualize the performance of CARD through the accuracy of other BNNs with the LeNet CNN (LeCun et al., 1998) architecture in Table 6, where the metrics were first reported in Tomczak et al.
For this dataset, our pre-trained classifier has the same
LeNet architecture as the baselines, which achieves a test accuracy of 91 .
CARD improves the mean test accuracy to 91 .
[Table]
We then present Table 7, from which we can draw the same conclusions as Table 5 on the CIFARdataset.
Note that we set α = 0 .
01 for the paired two-sample t
-test.
When making the prediction for each instance merely by the class with the narrowest PIW, we obtain a test accuracy of 89 .
[Table]
A.4 Test for Normality Assumption of Paired Two-Sample t -test
To assess the normality assumption of the paired two-sample t -test
[Table]
we inspect the Q-Q plots of the differences in probability between the most and the second most predicted classes within each test instance.
We include 16 instances in Figure 2 from CARD predictions on FashionMNIST dataset, each with 100 samples.
We observe that in all plots, the points align closely with the 45 -degree line, indicating that the normality assumption is valid.
A.5 Patch Accuracy vs Patch Uncertainty (PAvPU)
Besides the methods of assessing model confidence at the instance level introduced in this paper, we also consider an additional uncertainty evaluation metric in this section, Patch Accuracy vs Patch
Uncertainty (PAvPU) (Mukhoti and Gal, 2018), which measures the proportion of predictions that are either correct while the model is confident about them, or incorrect while the model is ambiguous.
Based on the t -test results, we can easily compute PAvPU, which is defined as
[Equation]
where n ac , n au , n ic , n iu represent the number of accurate (correct) predictions when the model is certain (confident) about them, accurate but uncertain, inaccurate but certain, as well as inaccurate and uncertain.
We apply the t -test results as the proxy for the model’s confidence level on each of its predictions.
A higher value indicates that the model tends to be correct when being confident, and to make mistakes when being vague — a characteristic that we want our model to possess.
On a related note, accuracy can be computed by replacing n iu with n au in Eq.
In the following section, we provide additional experimental results including this metric.
A.6 Classification on Noisy MNIST dataset
To further demonstrate the effectiveness of the CARD model for classification, especially in expressing model confidence, we run additional experiments on Noisy MNIST dataset (adding a Gaussian noise with mean 0 and variance 1 to each pixel).
Besides reporting PIW and t -test results similar to Table 5, we also compute PAvPU, and compare the results with baseline models in Fan et al.
(2021), i.e. , MC
Dropout (Gal and Ghahramani, 2016), Gaussian Dropout (Srivastava et al., 2014), Concrete Dropout (Gal et al., 2017), Bayes by Backprop (Blundell et al., 2015), and variants of Contextual Dropout (Fan et al., 2021).
Following the same experimental settings in Fan et al.
(2021), we apply a batch size of 128 for model training, and adopt the same MLP architecture with two hidden layers of 300 and 100 hidden units, respectively, each followed by a ReLU non-linearity, as the network architecture for the pre-trained classifier f ϕ ( x ) .
We simplify the diffusion network architecture (detailed in Section A.8) by reducing feature dimension from 2048 to 128 to match the model parameter scale for a fair comparison.
We pre-train f ϕ ( x ) for 100 epochs, and obtain a test set accuracy of 85 .
We train the diffusion model for 1000 epochs.
Unlike on CIFAR-10 or FashionMNIST dataset, we do not apply data normalization on the noisy MNIST dataset, following the settings in Fan et al.
Similar to Table 5, we report the mean PIW among correct and incorrect predictions, and the mean accuracy among instances rejected and not-rejected by the paired two-sample t -test, in Table 8.
Same as Fan et al.
(2021), we set α = 0 .
We report these metrics at the scope of the entire test set
[Table]
and for each true class label along with their group accuracy.
[Table]
From Table
[Table]
we are able to draw similar conclusions as in Table 5: across the entire test set, mean
PIW of the true class label among the correct predictions is much narrower than that of the incorrect predictions, implying that CARD is confident in its correct predictions, and tends to make mistakes when being vague.
When comparing mean PIWs at true class level, we observe that a more accurate class is inclined to have a larger difference between correct and incorrect predictions.
Meanwhile, similar to Table 5, the accuracy of test instances rejected by the t -test is much higher than that of the not-rejected ones, both across the entire test set and at the class level, while there are almost 10 times of not-rejected cases as those for CIFAR-10 task.
This result could have a more significant practical impact when applying human-machine collaboration: we are able to identify more than 6% of the data with a mean accuracy of less than 50% — if we pass these cases to human agents, we would be able to remarkably improve the classification accuracy, while still enjoying the automation by the machine classifier in the vast majority of test instances.
Furthermore, we contextualize the performance of CARD by reporting accuracy, PAvPU and NLL, along with those from the baseline models mentioned at the beginning of Section A.6, in Table 9.
The metrics of the other models are from Table 1 in Fan et al.
[Table]
We observe that CARD obtains an accuracy of 88 .
26% (improves from 85 .
50% by the pre-trained classifier f ϕ ), and a PAvPU of 89 .
12% , both are the best among all models.
This implies that our model is making not only accurate classifications, but also high-quality predictions in terms of model confidence.
Lastly, we apply temperature scaling (Guo et al., 2017) to calibrate the predicted probability for the computation of NLL, where the temperature parameter is tuned with the training set, and again obtain the best metric among all models.
A
7 Classification on Large
Scale Benchmark
Datasets
In this section, we demonstrate the generalizability of CARD on classification tasks with our proposed framework of evaluating instance-level model prediction confidence, particularly on large-scale datasets, by reporting the experimental results on CIFAR-100 ( 100 classes, 10 , 000 test instances),
ImageNet-100 ( 100 classes, 5 , 000 test instances), and ImageNet ( 1000 classes, 50 , 000 test instances).
For the CIFAR-100 dataset, we pre-train the deterministic base classifier f ϕ with a ResNetarchitecture, which achieves a test accuracy of 71 .
For the ImageNet-100 dataset, we apply a
ResNet-50 architecture and use the parameters of a linear classifier fine-tuned with the self-supervised recipe (He et al., 2020; Zheng et al., 2021) for f ϕ , which achieves a test accuracy of 82 . 30% .
For the ImageNet dataset, we adopt three different training paradigms for f ϕ , all using a ResNetarchitecture, but obtain different test accuracies: the first one has its parameters learned with the self-supervised pipeline, i.e. , the feature encoder of the ResNet-50 network is firstly pre-trained in a self-supervised manner with the loss proposed by Zheng et al.
(2021), and then by fixing the encoder the linear classifier of the network is further tuned with label supervision — this f ϕ achieves a test accuracy of 73 .
87% ; the second one reads the pre-trained weights provided by TorchVision, with the paradigm specified by Liang et al.
(2022), which achieves a test accuracy of 76 . 13%
; the third one also reads the pre-trained weights provided by TorchVision, with the paradigm specified by Pham and Le (2021), which achieves a test accuracy of 80 . 30% .
For each of the three large-scale benchmark datasets, we conduct 10 experimental runs, and report both majority-voted accuracy and PAvPU (with α = 0 .
01 for the paired two-sample t -test) by
CARD, along with the accuracy by the corresponding f ϕ , in Table 11.
We observe that under all circumstances, CARD is able to improve the accuracy from the base classifier f ϕ .
For the CIFAR-100 dataset with CARD, we also contextualize the performance of CARD through the accuracy of other BNNs with ResNet-18 architecture in Table 10, where the metrics were reported in
Tomczak et al.
[Table]
Regarding instance-level model prediction uncertainty assessment, we pick one run for each dataset, and report PIW among correct and incorrect predictions, at the entire test set level and at the true class level.
Since each dataset has either 100 or 1000 total number of classes, we only report PIW for the class with the most and the least accurate predictions, as well as the mean accuracy given the t -test rejection status at the whole test set level.
Furthermore, we record the test accuracy when making the prediction for each instance merely by the class with the narrowest PIW.
We report these metrics for all three large-scale datasets in Table 12.
For all experimental runs, we are able to draw conclusions consistent with those from the smaller-scale benchmark datasets (CIFARwith Table 5, FashionMNIST with Table 7, and Noisy MNIST with Table 8): relative variability in label reconstruction captured by true label PIW is strongly related to prediction correctness, with sharper contrast between correct and incorrect predictions in a more accurate class; meanwhile, the accuracy of instances not rejected by the t
-test is much lower than that of the rejected ones, indicating a great potential of improvement in prediction accuracy if combined with human inspection for the not-rejected cases.
A.8 General Experiment Setup Details
In this section, we provide the experimental setup for the CARD model in both regression and classification tasks.
Training : As mentioned at the beginning of Section 4, we set the number of timesteps to 1000 , and adopt a linear β t schedule same as Ho et al.
We set the learning rate to 0 .
001 for all tasks.
We use the AMSGrad (Reddi et al., 2018) variant of the Adam optimizer (Kingma and Ba, 2015) for all regression tasks.
We use the Adam optimizer for the classification tasks on all presented datasets, and adopt cosine learning rate decay (Loshchilov and Hutter, 2017).
We use exponentially weighted
[Table] [Table]
moving averages (Cox, 1961) on model parameters with a decay factor of 0 . 9999 .
We adopt antithetic sampling (Ren et al., 2019) to draw correlated timesteps during training.
We set the number of epochs at 5000 by default for regression tasks, and 1000 by default for classification tasks, to sufficiently cover the timesteps with T = 1000 .
The batch size for each UCI regression task are reported in Table 15.
We also apply a batch size of 256 for all toy regression tasks and classification tasks.
For all UCI regression tasks, we follow the convention in Hernández-Lobato and Adams (2015) and standardize both the input features and the response variable to have zero mean and unit variance, and remove the standardization to compute the metrics.
For all toy regression tasks, we do not standardize the input feature; we only standardize the response variable on the log-log cubic regression task.
For classification on CIFAR-10 and FashionMNIST, we normalize the dataset with the mean and standard deviation of the training set.
Network Architecture :
For the diffusion model, we adopt a simpler network architecture than that in previous work (Xiao et al., 2022; Zheng et al., 2022), by first changing the Transformer sinusoidal position embedding to linear embedding for the timestep.
As the network ϵ θ (cid:0) x , y t , f ϕ ( x ) , t (cid:1) has three other inputs besides the timestep t , we integrate them in different ways for regression and classification tasks:
• For regression, we first concatenate x , y t , and f ϕ ( x ) , then send the resulting vector through three fully-connected layers, all with an output dimension of 128 .
We perform Hadamard product between each of the output vector with the corresponding timestep embedding, followed by a Softplus non-linearity, before sending the resulting vector to the next fullyconnected layer.
Lastly, we apply a 4 -th fully-connected layer to map the vector to one with a dimension of 1 , as the output forward diffusion noise prediction.
We summarize the architecture in Table 13 (a).
• For classification on CIFAR-10, we first apply an encoder on the flattened input image (originally 32 × 32 × 3 ) to obtain a representation with 4096 dimensions.
The encoder consists of three fully-connected layers with an output dimension of 4096 .
Meanwhile, we concatenate y t and f ϕ ( x ) , and apply a fully-connected layer to obtain an output vector of 4096 dimensions.
We perform a Hadamard product between such vector and a timestep embedding to obtain a response embedding conditioned on the timestep.
We then perform Hadamard product between image embedding and response embedding to integrate these variables, and send the resulting vector through two more fully-connected layers withoutput dimensions, each would first followed by a Hadamard product with a timestep embedding, and lastly a fully-connected layer with an output dimension of 1 as the noise prediction.
Note that all fully-connected layers are also followed by a batch normalization layer and a Softplus non-linearity, except the output layer.
We summarize the architecture in Table 13 (b).
(a) Regression network architecture.
input: x , y t ,
[Table]
ϕ ( x ) ,
[Table] [Table]
For the pre-trained model f ϕ ( x )
[Table]
we adjust the functional form and training scheme based on the task.
For regression, we adopt a feed-forward neural network with two hidden layers, each with 100 and 50 hidden units, respectively.
We apply a Leaky ReLU non-linearity with a 0 .
01 negative slope after each hidden layer.
In practice, we find that when the dataset size is small (most of the UCI tasks have less than 10 , 000 data points
[Table]
and several around or less than 1000 ), a deep neural network f ϕ ( x ) is prone to overfitting.
We thus set the default number of epochs to 1000 , and adopt early stopping with a patience of 50 epochs, i.e. , we terminate the training if there is no improvement in the validation set
MSE for 50 consecutive epochs.
We split the original training set with 60% / 40% ratio and apply early stopping to find the optimal number of epochs, then train f ϕ ( x ) on the full training set.
For classification, we apply a pre-trained ResNet-18 network for CIFAR-10 dataset.
We only train the model with 10 epochs, as more would lead to overfitting.
We apply the Adam optimizer for f ϕ ( x ) in all tasks, and we only pre-train the model and freeze it during the training of the diffusion model, instead of fine-tuning it.
A.9 UCI Baseline Model Experiment Setup Details and Dataset Information
In this section, we first provide the experimental setup for the UCI regression baseline models (PBP,
MC Dropout, Deep Ensembles, and GCDS), including learning rate, batch size, network architecture, number of epochs, etc.
We applied the GitHub repo (Joachims, 2021) to run BNN models, and implemented our own version of GCDS (Zhou et al., 2021) since the code has not been published.
We note that GCDS is related to a concurrent work of Yang et al.
(2022), who share a comparable idea but use it in a different application:
regularizing the learning of an implicit policy in offline reinforcement learning.
Overall, we apply the same learning rate of 0 .
001 for all models on all datasets, except for PBP on the Boston dataset, which is 0 .
We also apply the Adam optimizer for all experiments.
We follow the convention in Hernández-Lobato and Adams (2015) and standardize both the input features and response variable for training, and remove the standardization for evaluation.
For batch size, we adjust on a case-by-case basis, taking the running time and dataset size into consideration.
We provide the batch size in Table 15.
For network architecture, we use ReLU non-linearities for all 3 BNNs, and Leaky ReLU with a 0 .
01 negative slope for GCDS; we choose the number of hidden layers with the number of hidden units per layer from the following 3 options: a)hidden layer with 50 hidden units; b) 1 hidden layer with 100 hidden units; c) 2 hidden layers with 100 and 50 hidden units, respectively.
We show the choice of hidden layer architecture in Table 16.
For the number of training epochs, we also vary on a case-by-case basis: PBP and Deep Ensembles both applied 40 epochs, but we observed in many experiments that the model has not converged.
We show the number of epochs in Table 17.
Lastly, datasets Boston, Energy, and Naval all contain one or more categorical variables, thus we ran the experiments both with and without conducting one-hot encoding on the data.
We found that except the Naval dataset with PBP, all other cases had worse metrics when one-hot encoding was applied.
We summarize the dataset information in terms of their size and number of features in Table 14.
[Table] [Table]
We reiterate that we re-ran the experiments with the baseline BNN models to compute the new metric
QICE along with the conventional metrics RMSE and NLL.
We carefully tuned the hyperparameters to obtain results better than or comparable with the ones reported in the original papers
[Table]
A.10 UCI Regression Tasks PICP across All Methods
In this section
[Table]
we report PICP for all methods in Table 18 from the same runs with the corresponding metrics in Tables 1, 2, and 3.
[Table] [Table]
[Figure]
A.11 Ablation Study on Choice of Prior — UCI Boston Dataset
In this section, we conduct ablation study for two model variants with different prior distribution settings on the UCI Boston dataset, under various settings of the number of timesteps T with adjusted β t linear schedule (to make sure that √ ¯ α 1 is close to 1 and √ ¯ α T is close to 0 ).
We report the evaluation metrics in Table 19, where we compare the original CARD setting with N ( f ϕ ( x ) , I ) as the prior distribution at timestep T , to the alternative setting with N ( 0 , I ) as the prior distribution.
We observe that as T decreases, RMSE and NLL do not deteriorate for N ( f ϕ ( x ) , I ) prior (CARD setting), but those from N ( 0 , I ) prior become worse.
The metrics that measure distributional fitting,
QICE and PICP, gets worse under the N ( f ϕ ( x ) , I ) prior setting as well, but such deterioration is not as much as N ( 0 , I ) prior.
The results indicate that our setting of an informative prior N ( f ϕ ( x ) , I ) contributes to the regression performance of CARD.
Furthermore, the setting of the total number of timesteps T does not affect the mean estimation for N ( 0 , I ) prior, but would noticeably impact the distributional fitting ( i.e. , the recovery of aleatoric uncertainty).
A.12 Ablation Study on Diffusion Network Parameterization — CIFAR-10 Dataset
In this section, we study the impact of different ϵ θ network parameterization forms on the CIFARdataset, through model performance in terms of accuracy and PAvPU, as well as training efficiency at the first 100 epochs.
We compare four model variants, each with a different prior and ϵ θ network parameterization combination, in Table 20, by reporting accuracy and PAvPU on the test set overruns.
We observe that given the same prior distribution setting, both metrics do not differ much by whether or not we include f ϕ ( x ) as the input of the ϵ θ network.
Meanwhile, both model variants (V1, V2) with a prior of N ( f ϕ ( x ) , I ) outperform the other two variants (V3, V4) of N ( 0 , I ) prior, suggesting the application of an informative prior would benefit the performance.
Furthermore, the variant (V4) with f ϕ ( x ) as neither the prior mean nor ϵ θ input has the worst performance, indicating the inclusion of a pre-trained classifier can improve the model performance in both accuracy and uncertainty estimation.
[Table] [Table]
Furthermore
[Table]
the choice of N ( f ϕ ( x )
[Table]
I ) prior also helps with training efficiency: we observe in
Figure 3 that the model performance improved faster for N ( f ϕ ( x ) , I ) prior at the beginning of training, by measuring the accuracy on the test set with 1 sample every 10 epochs for the firstepochs during training, and plotting the metric (as the mean across all runs) against the number of epochs.
Due to the measurement similarity, we omit V2 and V4 and only plot the metrics from
V1 (for N ( f ϕ ( x ) , I ) prior) and V3 (for N ( 0 , I ) prior).
We observe that after only 20 epochs, the accuracy of 1 sample by CARD is already close to 90% , while the variant with a N ( 0 , I ) prior is only around 75% , suggesting the advantage in training efficiency with an informative prior.
A.13 Regression Toy Example Details
The 8 toy examples are summarized by Table 21.
For each task, we create the dataset by sampling 10 , 240 data points from the data generating function, and randomly split them into training and test sets with an 80% / 20% ratio.
For all uni-modal cases as well as the full circle task, the x variable is sampled from a uniform distribution.
The noise variable ϵ is sampled from a Gaussian distribution.
The dataset of the inverse sinusoidal task is created by simply swapping x and y variable of the sinusoidal task (so that we have multi-modality when the new x is roughly between 0 .
25 and 0 . 75 ), thus the name of the task.
To quantitatively evaluate the performance of CARD, we generate 1000 y samples for each x in the test set, and compute the corresponding metrics.
We conduct such a procedure over 10 runs, each applying a different random seed to generate the dataset, and report the mean and standard deviation over all runs for each metric.
For all tasks regardless of the form of p ( y | x ) , we compute PICP and
QICE.
For tasks with uni-modal p ( y | x ) distributions, we summarize the 1000 samples for each test x by computing their mean, as an unbiased estimator to E ( y | x ) , and compute the root mean squared error (RMSE) between the estimated and true conditional means.
For all tasks, we obtain a mean
PICP very close to the optimal 95% , and most of the tasks have a mean QICE value far less than 0 .
01 except log-log cubic regression, which also has a mean RMSE noticeably larger by an order of magnitude among cases with uni-modal conditional distributions.
Note that the y samples here have a much wider range: as x increases from 0 to 10 , y increases from 0 to over 1200 , resulting in
[Table]
a much more difficult task.
Therefore, the metrics reported here can be viewed with relativity, and combined with the qualitative conclusions from Figure 1.
The metrics of all tasks, including RMSE,
QICE, and PICP, are recorded in Table 22.
Note that QICE has been converted to a percentage scale as we report two significant figures for all metrics.
The results in Table 22 implicitly suggest that our proposed metric QICE is reasonable: when RMSE is low (way below 1 ) and PICP is close to 95% , implying that CARD is performing well in terms of both mean estimation and distributional matching, QICE is also low (far less than 1% ); for the most difficult task, log-log cubic regression, as RMSE is above 5 and PICP deviates relatively most from 95% (but not much), QICE also has the largest value (slightly above 1% ).
A.14 The Evolution of Samples through the Diffusion Process
We present the evolution of both q and p distribution samples through the forward and reverse diffusion process, respectively.
We first visualize the behaviors of these samples from the training on linear regression tasks in Figure 4, where we pick timesteps with an interval of 200 steps including the 1 st and the last timestep, namely t = 1 , 200 , 400 , 600 , 800 , T .
The p samples presented are from near the end of training.
We observe that ϵ θ has been trained to match the q samples at different timesteps well, including the variance.
Furthermore, note that the true variance from the data generating function is set to 4 , while the prior p ( y T | x ) has a variance of 1 .
We can observe the gradual increase of variance in the reverse direction.
This example helps to illustrate that when f ϕ ( x ) can already estimate the mean accurately, it makes the task for the diffusion model easier: in this case to solely focus on recovering the aleatoric uncertainty.
Similarly, we present the samples from q and p distribution during training for the full circle regression task in Figure 5.
Besides observing the matching in samples at all selected timesteps, we emphasize
CARD’s ability to model multi-modality at various intensities.
As t increases, we observe the samples gradually evolve from a uni-modal distribution into a multi-modal one, and the diffusion model is able to capture such progress.
To quantify such match, we plot the quantile coverage ratios for samples at t = 0 from one run, along with the optimal coverage ratio ( 0 . 1 , for 10 bins), in Figure 6.
Note that we obtain a QICE of 0 .
62 in this run.
We observe that CARD samples cover the true data with a ratio close to the optimal across all bins; The 5 th bin has relatively the most deviation from the optimal ratio (which is understandable as the full circle dataset has a bi-modal distribution across
[Table] [Table]
most x , with no data points in the center portion), which is compensated by the 2 nd , 4 th and last bin with coverage slightly above the optimal ratio.
We continue with a plot of samples during test time from the UCI Boston dataset.
In Figure 7, we plot the generated samples from p (in blue) along with q samples (in red) at various t .
The x -axis represents the count of samples, instead of the actual x since the true covariate space is high-dimensional.
Note that we generate 1000 samples given each x .
While still observing the good mix between q and p samples for t = 200 , .
, T from 2 nd plot to the right, we observe that for t = 1 , all samples for each x forms a vertical region that covers the corresponding y 1 (which shall be very close to y
due to the linear β t schedule) from q distribution at various positions ( i.e. , middle, upper half, lower half, near top, near bottom).
We observe that the samples are representative of the true conditionals p ( y | x = x ) for each x .
A.15 The Development of Model Performance through the Reverse Diffusion Process
Following the demonstration of behavior change in samples with respect to timestep t during both the training and test time, we present the change in model evaluation metrics on the test set as a function of t .
We again use the UCI Boston dataset, and compute all evaluation metrics, including RMSE,
NLL, QICE, and PICP, at all timesteps from t =
T to t = 0 .
Since the standard procedure for running the task contains 20 different splits on the dataset, we compute these metrics at all timesteps for all splits, and take the mean across all splits at each timestep t .
We combine these plots in Figure 8.
For
RMSE, we observe that the performance at t =
T is already quite good, due to the setting of f ϕ ( x ) as the prior mean; as the reverse process continues, the metric gradually improves by decreasing.
Both NLL and QICE behave in a similar fashion: as t decreases, the metric steadily improves.
For
PICP, note that it crosses the optimal value of 0 .
95 coverage ratio around the end of the reverse process; however, it did not deviate much from such value.
This plot demonstrates the successive improvements across all metrics during the reverse diffusion process, starting from an already decent place (in terms of RMSE and NLL) due to the application of an informative prior.
A.16 Improving the Granularity of ECE from Subgroup to Instance Level
In this section, we first present the definition of ECE.
This material is from Guo et al.
and we include it here for completeness.
We then provide our analysis, specifically about its granularity to measure prediction confidence by the model, which motivates us to introduce an alternative way to measure model prediction confidence at a finer granularity ( i.e. , at instance level) in our paper.
ECE is defined as:
[Equation]
[Equation]
where Y and ˆ Y are true and predicted class labels, respectively; ˆ P is the predicted probability associated with ˆ Y .
A perfect calibration is defined as:
[Equation]
However, since the predicted probability ˆ Y is continuous in [0 , 1] , we cannot compute ECE with finite instances, thus we approximate it by first dividing the probability space into M bins with equal width , then compute the confidence and accuracy within each bin.
Each test instance is placed into one specific bin by the predicted probability value associated with the true class label.
For the m -th bin B m , we have accuracy (proportion of correct predictions)
[Equation]
(33) and confidence (mean of predicted probabilities)
[Equation]
( B m
[Equation]
where ˆ y i and ˆ p i are the predicted label and its associated probability value, and y i is the true label, for instance i .
We thus have the empirical version of ECE as:
[Equation]
where | B m | and n are the cardinality of the m -th bin and the total number of instances, respectively.
To summarize, although we are interested in measuring the miscalibration through the difference between p ( y i
=
ˆ y i | x i ) and ˆ p
i , we are only able to compute such miscalibration at the granularity of subgroup level — usually with the number of subgroups M set to 10 or less in practice.
In other words, we cannot make a statement with the existing classification framework like the following: given this new test instance, we predict the class label to be (some class), but we are very sure our prediction is correct.
This observation motivates us to introduce an alternative way of measuring model confidence, at the granularity of the instance level .
A.17 Insights on How CARD Accurately Recovers the Conditional Distributions
Although a theoretical justification is not within the scope of our paper, in this section we plan to briefly talk about what makes CARD stands out as a great candidate to model p ( y | x , D ) , through the capability to model implicit distributions by diffusion models in general: the theory of stochastic processes by Feller (1949) suggests that:
a) With a large enough number of timesteps T , q ( x T | x 0 ) would converge to a stationary distribution p ( x T ) regardless of the distribution at timestep t = 0 , q ( x 0 ) .
In other words, we are able to go from any distribution q ( x 0 ) to a stationary distribution p ( x T ) by choice.
b) Meanwhile, with a large enough T
and small enough noise schedule { β t } t =1: T , the product in q ( x t − 1 | x t ) ∝ q ( x t | x t − 1 ) q
( x t − 1 ) would be dominated by q ( x t | x t − 1 ) , thus both forward and reverse diffusion processes would share the same functional form.
Although q ( x t − 1 | x t ) cannot be easily estimated, if we are able to learn a function p θ ( x t − 1 | x t ) that approximates q ( x t − 1 | x t ) well, we are able to reverse the direction mentioned in a) and go from p ( x T ) to any q ( x 0 ) .
For real world datasets like the ones in Dua and Graff (2017), the relationship between the covariates and response variable can be quite complicated.
The class of diffusion models in general, including
CARD, places no restriction on the parametric form for q ( x 0 ) ( i.e. , it fits the data as it is), therefore it is suitable to the situations where a flexible distribution assumption is needed, instead of just the ones where an explicit distribution assumption is valid ( e g. , Gaussian for BNNs).
A.18 Insights on Why CARD Outperforms Other BNN Approaches
We observe the following two limitations of the class of BNN approaches:
a) It places an explicit distributional form assumption to p ( y | x , W ) , where W denotes the model parameter: for regression, it assumes an additive Gaussian noise model for p ( y | x , W ) (Eq. 2 in Kendall and Gal (2017))
— we have addressed the limitation of such additive-noise assumption in the first two paragraphs of Section 1.
b) BNNs do not directly fit the actual posterior p ( W | X , Y ) , which is required for evaluating the marginal p ( Y | X ) , due to its intractability, but rather fit an approximated distribution q ( W ) that minimizes its KL divergence to the actual posterior.
Such distribution q ( W ) has a simple distributional assumption (usually Gaussian), which places another layer of restrictions for BNNs to model their predictive distribution p ( y | x ) =
(cid:82) p ( y | x , W ) p ( W | X , Y )
d W .
CARD is able to dodge both limitations through the modeling of implicit distributions, as elaborated in Section A.17.
[Figure]
B Broader Impact and Limitations
We believe that our model has a practical impact in various industrial settings, where supervised learning methods have been increasingly applied to facilitate the decision-making process.
For regression tasks, e.g. , understanding the relationship between drug dosage and biographical features of a patient in the medical domain, and evaluating player performance given various on-court measurements, where the actual distribution of the real-world data is complicated and unknown, we are able to compute summary statistics with a minimal amount of assumptions, as we do not assume the parametric form of the conditionals p
( y | x ) .
The analytical results from our framework thus have the potential to reach a broader audience, who in the past might be hindered by the sheer amount of jargon due to the lack of statistical training.
For classification tasks, as mentioned in both of the experiments, we could easily adopt a human-machine collaboration framework: since our model is capable of conveying the prediction confidence along with the prediction itself, we could pass the cases where the model is less assertive to humans for further evaluation.
This trait is especially valuable for classification tasks with exceptionally imbalanced data, e.g. , fraud detection, and ad click-through rate prediction, where the volume of one class could be orders of magnitude more than the other.
False negative errors for these applications are usually quite expensive, and simply adjusting the classification threshold would often put too many positive predictions for human agent evaluation.
As demonstrated in our experiments, CARD is capable of providing uncertain cases with a very reasonable ratio, keeping the workload for human agents at a sensible level.
Meanwhile, since CARD is capable of modeling multi-modality, we are concerned that it could be devised for malicious purposes, like revealing personalized information of the patient through reverse engineering the prediction results: as an extension to the medical example of breast cancer given in the introduction section, one could tell with high confidence the gender of the patient based on the predicted mode.
For research purposes, in this work, we only consider Gaussian diffusion and the reverse denoising in CARD, while there could be much more options when given different data.
For example, in classification, we can optimize the classification likelihood with cross-entropy instead of using simple MSE loss, and directly perform diffusion in discrete spaces, as in (Austin et al., 2021).
We only take a pre-trained model f ϕ as a deterministic neural network, while there could be more possibilities like combining BNN methods with CARD.
Moreover, the computation efficiency of
CARD may also be further investigated if the dataset size becomes larger.
We encourage researchers in our community to further study those potential safety concerns and approaches for improvements in order to develop more mature supervised learning tools
[Table]
C Computational Resources
Our models are trained and evaluated with a single Nvidia GeForce RTX 3090 GPU.
We use
PyTorch (Paszke et al., 2019) 1.10.0 as the deep learning framework.
CARD trains between 100 and 200 steps per second at the batch size specified in Table 15 for regression tasks, and at 44 steps per second at batch size 256 for classification on the CIFAR-10 dataset.
The sampling for a batch oftest instances, each with 100 samples, takes around 1 .
05 seconds at most for the classification task on FashionMNIST.
The computation time could vary if we apply different network architectures for regression and classification tasks, and the architecture details are provided in Appendix A.
[Table] [Table]
We summarize the model parameter size and measure the throughputs, i
[Table]
e. , how many data samples can be proceeded per second, as computation complexity measure in Table 23.
As our model consists of both a diffusion model ϵ θ in the response prediction and a pre-trained prior mean model f ϕ , we compute them respectively.