Classification-denoising networks

## Abstract

Abstract Image classification and denoising suffer from complementary issues of lack of robustness or partially ignoring conditioning information. We argue that they can be alleviated by unifying both tasks through a model of the joint probability of (noisy) images and class labels. Classification is performed with a forward pass followed by conditioning. Using the Tweedie-Miyasawa formula, we evaluate the denoising function with the score, which can be computed by marginalization and back-propagation. The training objective is then a combination of cross-entropy loss and denoising score matching loss integrated over noise levels. Numerical experiments on CIFAR-10 and ImageNet show competitive classification and denoising performance compared to reference deep convolutional classifiers/denoisers, and significantly improves efficiency compared to previous joint approaches. Our model shows an increased robustness to adversarial perturbations compared to a standard discriminative classifier, and allows for a novel interpretation of adversarial gradients as a difference of denoisers.

## 1 Introduction: classification and denoising

Image classification and denoising are two cornerstone problems in computer vision and signal processing.
The former aims to associate a label $c\in\{1,\ldots,C\}$ to input images $\mathbf{x}$. The latter involves recovering the image $\mathbf{x}$ from a noisy observation $\mathbf{y}=\mathbf{x}+\sigma\boldsymbol{\epsilon}$.
Before the 2010s, these two problems were addressed with different kinds of methods but similar mathematical tools like wavelet decompositions, non-linear filtering and Bayesian modeling.
Since the publication of AlexNet (Krizhevsky et al., ),
deep learning (LeCun et al., ) and convolutional neural network (CNNs) (LeCun et al., ) have revolutionized both fields.
ResNets (He et al., ) and their recent architectural and training improvements (Liu et al., ; Wightman et al., ) still offer close to state-of-the-art accuracy, comparable with more recent methods like vision transformers (Dosovitskiy et al., ) and visual state space models (Liu et al., ).
In image denoising, CNNs lead to significant improvements with the seminal work DnCNN (Zhang et al., ) followed by FFDNet (Zhang et al., ) and DRUNet (Zhang et al., ).
Importantly, deep image denoisers are now at the core of deep generative models estimating the gradient of the distribution of natural images (Song & Ermon, ), a.k.a. score-based diffusion models (Ho et al., ).

However, some unsolved challenges remain in both tasks. For one, classifiers tend to interpolate their training set, even when the class labels are random (Zhang et al., ), and are thus prone to overfitting. They also suffer from robustness issues such as adversarial attacks (Szegedy, ). Conversely, deep denoisers seem to neither overfit nor memorize their training set when it is sufficiently large (Yoon et al., ; Kadkhodaie et al., ).
On the other hand, when used to generate images conditionally to a class label or a text caption, denoisers are known to occasionally ignore part of their conditioning information (Conwell & Ullman, ; Rassin et al., ), requiring ad-hoc techniques like classifier-free guidance (Ho & Salimans, ) or specific architecture and synthesis modifications (Chefer et al., ; Rassin et al., ). Another issue is that optimal denoisers should be conservative vector fields but DNN denoisers are only approximately conservative (Mohan et al., ), and enforcing this property is challenging (Saremi, ; Chao et al., ).

We introduce a conceptual framework which has the potential to address these issues simultaneously. We propose to learn a single model parameterizing the *joint* log-probability $\log p(\mathbf{y},c)$ of noisy images $\mathbf{y}$ and classes $c$. Both tasks are tackled with this common approach, aiming to combine their strengths while alleviating their weaknesses.
First, the model gives easy access to the conditional log-probability $\log p(c|\mathbf{y})$ by conditioning, allowing to classify images with a single forward pass.
Second, we can obtain the marginal log-probability $\log p(\mathbf{y})$ by marginalizing over classes $c$, and compute its gradient with respect to the input $\mathbf{y}$ with a backward pass.
The denoised image can then be estimated using the Tweedie-Miyasawa identity (Robbins, ; Miyasawa et al., ; Raphan & Simoncelli, ). We can also perform class-conditional denoising similarly using $\nabla_{\mathbf{y}}\log p(\mathbf{y}|c)$.

Previous related works in learning joint energy-based models (Grathwohl et al., ) or gradient-based denoisers (Cohen et al., ; Hurault et al., ; Yadin et al., ) have faced two key questions, respectively concerning the training objective and network architecture. Indeed, learning a probability density over high-dimensional images is a very challenging problem due to the need to estimate normalization constants, which has only been recently empirically solved with score-matching approaches (Song et al., ). Additionally, different architectures, and therefore inductive biases, are used for both tasks: CNN classifiers typically have a feedforward architecture which maps an image $\mathbf{x}$ to a logits vector $(\log p(c|\mathbf{x}))_{1\leq c\leq C}$, while CNN denoisers have a UNet encoder/decoder architecture which outputs a denoised image $\hat{\mathbf{x}}$ with the same shape as the input image $\mathbf{x}$. The joint approach requires unifying these two architectures in a single one whose *forward* pass corresponds to a classifier and *forward plus backward* pass corresponds to a denoiser, while preserving the inductive biases that are known to work well for the two separate tasks.

Here, we propose principled solutions to these questions. As a result of our unifying conceptual framework, we derive a new interpretation of adversarial classifier gradients as a difference of denoisers, which complements previous connections between adversarial robustness and denoising. Our approach also opens new research directions: having direct access to a log-probability density $\log p(\mathbf{y},c)$ can be expected to lead to new applications, such as out-of-distribution detection or improved interpretability compared to score-based models.

The contributions of this paper are the following:

- •
We introduce a framework to perform classification, class-conditional and unconditional denoising with a single network parameterizing the joint distribution $p(\mathbf{y},c)$. The two training objectives naturally combine in a lower-bound on the likelihood of the joint model.
Further, our approach evidences a deep connection between adversarial classifier gradients and (conditional) denoising.
Pursuing this line of research thus has the potential to improve both classifier robustness and denoiser conditioning.
- •
We propose an architecture to parameterize the joint log-probability density of images and labels which we call GradResNet. It makes minimal modifications to a ResNet architecture to incorporate inductive biases from UNet architectures appropriate to denoising (when computing a backward pass), while preserving those for classification (in the forward pass).
- •
We validate the potential of our method on the CIFAR-10 and ImageNet datasets. In particular, our method is significantly more efficient and scalable than previous approaches (Grathwohl et al., ; Yang & Ji, ; Yang et al., ). Additionally, we show that the denoising objective improves classification performance and robustness.

We motivate our approach through the perspectives of joint energy modeling and denoising score matching in Section 2. We then present our method in detail in Section 3, and evaluate it numerically in Section 4. We discuss our results in connection with the literature in Section 5.
We conclude and evoke future research directions in Section 6.

## 2 Joint energy-score models

Consider a dataset of labeled images $(\mathbf{x}_{i},c_{i})_{1\leq i\leq n}$ with images $\mathbf{x}_{i}\in\mathbb{R}^{d}$ and class labels $c_{i}\in\{1,\dots,C\}$ of i.i.d. pairs sampled from a joint probability distribution $p(\mathbf{x},c)$. Typical machine learning tasks then correspond to estimating conditional or marginal distributions: training a classifier amounts to learning a model of $p(c|\mathbf{x})$, while (conditional) generative modeling targets $p(\mathbf{x})$ or $p(\mathbf{x}|c)$. Rather than solving each of these problems separately, this paper argues for training a *single* model $p_{\theta}(\mathbf{x},c)$ of the *joint* distribution $p(\mathbf{x},c)$, following Hinton (); Grathwohl et al. (). The conditional and marginal distributions can then be recovered from the joint model with

$$ $\displaystyle p_{\theta}(c|\mathbf{x})$ $\displaystyle=\frac{p_{\theta}(\mathbf{x},c)}{\sum_{c=1}^{C}p_{\theta}(\mathbf {x},c)},$ $\displaystyle p_{\theta}(\mathbf{x})$ $\displaystyle=\sum_{c=1}^{C}p_{\theta}(\mathbf{x},c),$ $\displaystyle p_{\theta}(\mathbf{x}|c)$ $\displaystyle=\frac{p_{\theta}(\mathbf{x},c)}{p_{\theta}(c)}.$ (1) $$

We note that $p_{\theta}(c)$ is intractable to compute, but in the following we will only need the score of the conditional distribution $\nabla_{\mathbf{x}}\log p_{\theta}(\mathbf{x}|c)$, which is equal to $\nabla_{\mathbf{x}}\log p_{\theta}(\mathbf{x},c)$ independently of $p_{\theta}(c)$.

In Section 2.1, we motivate the joint approach and detail its potential benefits over separate modeling of the conditional distributions. We then extend this to the context of diffusion models in Section 2.2, which leads to an interpretation of adversarial gradients as a difference of denoisers.

### 2.1 Advantages of joint over conditional modeling

We first focus on classification. Models of the conditional distribution $p(c|\mathbf{x})$ derived from a model of the joint distribution $p(\mathbf{x},c)$ are referred to as *generative* classifiers, as opposed to *discriminative* classifiers which directly model $p(c|\mathbf{x})$. The question of which approach is better goes back at least to Vapnik ().
It was then generally believed that discriminative classifiers were better: quoting Vapnik (), “when solving a given problem, try to avoid solving a more general problem as an intermediate step”. This has led the community to treat the modeling of $p(\mathbf{x})$ and $p(c|\mathbf{x})$ as two separate problems, though there were some joint approaches (Ng & Jordan, ; Raina et al., ; Ulusoy & Bishop, ; Lasserre et al., ; Ranzato et al., ).
In the deep learning era, the joint approach was revitalized by Grathwohl et al. () with several follow-up works (Liu & Abbeel, ; Grathwohl et al., ; Yang & Ji, ; Yang et al., ). They showed the many benefits of generative classifiers, such as better calibration and increased robustness to adversarial attacks. It was also recently shown in Jaini et al. () that generative classifiers are much more human-aligned in terms of their errors, shape-vs-texture bias, and perception of visual illusions.
We reconcile these apparently contradictory perspectives by updating the arguments in Ng & Jordan () to the modern setting.

Figure: Figure 1: Illustration of the generalization bounds $b+\frac{v}{n}$ in two idealized settings with stylized values for $b$ and $v$. Left: bias-dominated setting with $b^{\mathrm{gen}}=5$, $b^{\mathrm{dis}}=1$, $v^{\mathrm{gen}}=20$, $v^{\mathrm{dis}}=100$. Right: variance-dominated setting with $b^{\mathrm{gen}}=b^{\mathrm{dis}}=1$, $v^{\mathrm{gen}}=100$, $v^{\mathrm{dis}}=10000$.
Refer to caption: x1.png

Consider that we have a parametrized family $\mathopen{}\mathclose{{}\left\{p_{\theta}(\mathbf{x},c),\theta\in\mathbb{R}^{m
}}\right\}$ (for instance, given by a neural network architecture). Generative and discriminative classifiers are respectively trained to maximize likelihood or minimize cross-entropy:

$$ $\displaystyle\theta_{n}^{\mathrm{gen}}$ $\displaystyle=\operatorname*{arg\,max}_{\theta}\ \frac{1}{n}\sum_{i=1}^{n}\log p _{\theta}(\mathbf{x}_{i},c_{i}),$ $\displaystyle\theta_{n}^{\mathrm{dis}}$ $\displaystyle=\operatorname*{arg\,max}_{\theta}\ \frac{1}{n}\sum_{i=1}^{n}\log p _{\theta}(c_{i}|\mathbf{x}_{i}).$ (2) $$

We measure the expected generalization error of the resulting classifiers in terms of the Kullback-Leibler divergence on a test point $\mathbf{x}\sim p(\mathbf{x})$:

$$ $\varepsilon(\theta)=\mathbb{E}_{\mathbf{x}\sim p(\mathbf{x})}\mathopen{} \mathclose{{}\left[\operatorname{KL}\mathopen{}\mathclose{{}\left(p(c|\mathbf{ x})\,\middle\|\,p_{\theta}(c|\mathbf{x})}\right)}\right].$ (3) $$

We show that it can be described with “bias” and “variance” constants $b^{\mathrm{gen}}$, $b^{\mathrm{dis}}$, $v^{\mathrm{gen}}$, $v^{\mathrm{dis}}$:

$$ $\displaystyle\mathbb{E}[\varepsilon(\theta_{n}^{\mathrm{gen}})]$ $\displaystyle=b^{\mathrm{gen}}+\frac{v^{\mathrm{gen}}}{2n}+o\mathopen{} \mathclose{{}\left(\frac{1}{n}}\right),$ $\displaystyle\mathbb{E}[\varepsilon(\theta_{n}^{\mathrm{dis}})]$ $\displaystyle=b^{\mathrm{dis}}+\frac{v^{\mathrm{dis}}}{2n}+o\mathopen{} \mathclose{{}\left(\frac{1}{n}}\right),$ (4) $$

where the expected values average over the randomness of the training set.
This is derived with standard arguments in Appendix D, where the constants are explicited as functions of $p$ and $\{p_{\theta}\}$.
The bias arises from model misspecification, while the variance measures the sample complexity of the model, as we detail below.
We note that these results are only asymptotic, and the constants hidden in the little-$o$ notation could be exponential in the dimension. Nevertheless, these results provide evidence of the two distinct regimes found by Ng & Jordan (), as illustrated in Figure 1.

Which approach is better then depends on the respective values of the bias and variance constants.
The bias is the asymptotic error when $n\to\infty$, and thus only depends on approximation properties. It always holds that $b^{\mathrm{dis}}\leq b^{\mathrm{gen}}$, as discriminative classifiers directly model $p(c|\mathbf{x})$ and thus do not pay the price of modeling errors on $p(\mathbf{x})$.
The variance measures the number of samples needed to reach this asymptotic error. In the case of zero bias, we have $v^{\mathrm{gen}}\leq v^{\mathrm{dis}}$ (and further $v^{\mathrm{dis}}=m$ the number of parameters): generative classifiers learn faster (with fewer samples) as they exploit the extra information in $p(\mathbf{x})$ to estimate the parameters. With simple models with few parameters (e.g., linear models, as in Ng & Jordan ()), we can expect the bias to dominate, which has led the community to initially favor discriminative classifiers. On the other hand, with complex expressive models (e.g., deep neural networks) that have powerful inductive biases, we can expect the variance to dominate. In this case, generative classifiers have the advantage, as can be seen in the recent refocus of the community towards generative models and classifiers (Grathwohl et al., ; Jaini et al., ). The success of self-supervised learning also indicates the usefulness of modeling $p(\mathbf{x})$ to learn $p(c|\mathbf{x})$.

For similar reasons, a joint approach can also be expected to lead to benefits in conditional generative modeling. For instance, Dhariwal & Nichol () found that conditional generative models could be improved by classifier guidance, and Ho & Salimans () showed that these benefits could be more efficiently obtained with a single model.

### 2.2 Joint modeling with diffusion models

The joint approach offers significant statistical advantages, but also comes with computational challenges. Indeed, it requires to learn a model of a probability distribution over the high-dimensional image $\mathbf{x}$, while in a purely discriminative model it only appears as a conditioning variable (the probability distribution is over the discrete class label $c$). In Grathwohl et al. (), the generative model is trained directly with maximum-likelihood and Langevin-based MCMC sampling, which suffers from the curse of dimensionality and does not scale to large datasets such as ImageNet. We revisit their approach in the context of denoising diffusion models, which have empirically resolved these issues. We briefly introduce them here, and explain the connections with adversarial robustness in the context of generative classifiers.

#### Diffusion models and denoising.

In high-dimensions, computing maximum-likelihood parameters is typically intractable due to the need to estimate normalizing constants. As a result, Hyvärinen proposed to replace maximum-likelihood with score matching (Hyvärinen & Dayan, ), which removes the need for normalizing constants and is thus computationally feasible. However, its sample complexity is typically much larger as a result of this relaxation (Koehler et al., ). Song et al. () showed that this computational-statistical tradeoff can be resolved by considering a diffusion process (Sohl-Dickstein et al., ; Ho et al., ; Song & Ermon, ; Kadkhodaie & Simoncelli, ), where maximum-likelihood and score matching become equivalent.

Denoising diffusion models consider the joint distribution $p_{\sigma}(\mathbf{y},c)$ of noisy images $\mathbf{y}$ together with class labels $c$ for every noise level $\sigma$. Formally, the noisy image $\mathbf{y}$ is obtained by adding Gaussian white noise of variance $\sigma^{2}$ to the clean image $\mathbf{x}$:

$$ $\mathbf{y}=\mathbf{x}+\sigma\boldsymbol{\epsilon},\quad\boldsymbol{\epsilon} \sim\mathcal{N}(0,\mathrm{Id}).$ (5) $$

Note that the class label $c$ becomes increasingly independent from $\mathbf{y}$ as $\sigma$ increases.

Modeling $p(\mathbf{y})$ or $p(\mathbf{y}|c)$ by score matching then amounts to performing unconditional or class-conditional denoising (Vincent, ), thanks to an identity attributed to Tweedie and Miyasawa (Robbins, ; Miyasawa et al., ; Raphan & Simoncelli, ):

$$ $\displaystyle\nabla_{\mathbf{y}}\log p(\mathbf{y})$ $\displaystyle=\frac{\mathbb{E}\mathopen{}\mathclose{{}\left[\mathbf{x}\, \middle|\,\mathbf{y}}\right]-\mathbf{y}}{\sigma^{2}},$ $\displaystyle\nabla_{\mathbf{y}}\log p(\mathbf{y}|c)$ $\displaystyle=\frac{\mathbb{E}\mathopen{}\mathclose{{}\left[\mathbf{x}\, \middle|\,\mathbf{y},c}\right]-\mathbf{y}}{\sigma^{2}},$ (6) $$

see e.g. Kadkhodaie & Simoncelli () for proof. Note that $\mathbb{E}\mathopen{}\mathclose{{}\left[\mathbf{x}\,\middle|\,\mathbf{y}}\right]$ and $\mathbb{E}\mathopen{}\mathclose{{}\left[\mathbf{x}\,\middle|\,\mathbf{y},c}\right]$ are the best approximations of $\mathbf{x}$ given $\mathbf{y}$ (and $c$) in mean-squared error, and are thus the optimal unconditional and conditional denoisers. A joint model $p_{\theta}(\mathbf{y},c)$ thus gives us access to unconditional and class-conditional denoisers $\mathcal{D}_{\rm u}$ and $\mathcal{D}_{\rm c}$,

$$ $\displaystyle\mathcal{D}_{\rm u}(\mathbf{y})$ $\displaystyle=\mathbf{y}+\sigma^{2}\nabla_{\mathbf{y}}\log p_{\theta}(\mathbf{ y}),$ $\displaystyle\mathcal{D}_{\rm c}(\mathbf{y},c)$ $\displaystyle=\mathbf{y}+\sigma^{2}\nabla_{\mathbf{y}}\log p_{\theta}(\mathbf{ y}|c),$ (7) $$

which can be trained to minimize mean-squared error:

$$ $\displaystyle\min\$ $\displaystyle\mathbb{E}\mathopen{}\mathclose{{}\left[\|\mathbf{x}-\mathbf{y}- \sigma^{2}\nabla_{\mathbf{y}}\log p_{\theta}(\mathbf{y})\|^{2}}\right],$ $\displaystyle\min\$ $\displaystyle\mathbb{E}\mathopen{}\mathclose{{}\left[\|\mathbf{x}-\mathbf{y}- \sigma^{2}\nabla_{\mathbf{y}}\log p_{\theta}(\mathbf{y}|c)\|^{2}}\right].$ (8) $$

#### Adversarial gradients.

In this formulation, the adversarial classifier gradients (on noisy images) can be interpreted as a scaled difference of conditional and unconditional denoisers:

$$ $\nabla_{\mathbf{y}}\log p_{\theta}(c|\mathbf{y})=\nabla_{\mathbf{y}}\log p_{ \theta}(\mathbf{y}|c)-\nabla_{\mathbf{y}}\log p_{\theta}(\mathbf{y})=\frac{1}{ \sigma^{2}}\mathopen{}\mathclose{{}\left(\mathcal{D}_{\rm c}(\mathbf{y},c)- \mathcal{D}_{\rm u}(\mathbf{y})}\right).$ (9) $$

The adversarial gradient on clean images is obtained by sending the noise level $\sigma\to 0$, highlighting potential instabilities.
Equation 9 provides a novel perspective on adversarial robustness (which was implicit in Ho & Salimans ()): adversarial gradients are the details in an infinitesimally noisy image that are recovered when the denoiser is provided with the class information. Being robust to attacks, which requires small adversarial gradients, thus requires the conditional denoiser to mostly ignore the provided class information when it is inconsistent with the input image at small noise levels.
*The denoising objective (8) thus directly regularizes the adversarial gradients.*
We discuss other connections between additive input noise and adversarial robustness in Section 5.1.

#### Likelihood evaluation.

We also note that modeling the log-probability rather than the score has several advantages in diffusion models. First, it potentially allows to evaluate likelihoods in a single forward pass, as done in Choi et al. (); Yadin et al. (). Second, it leads to generative classifiers that can be evaluated much more efficiently than recent approaches based on score diffusion models (Li et al., ; Clark & Jaini, ; Jaini et al., ).

## 3 Architecture and training

The previous section motivated the joint approach and led to a unification between classification and denoising tasks. We now focus on these two problems, and describe our parameterization of the joint log-probability density (Section 3.1), the GradResNet architecture (Section 3.2), and the training procedure (Section 3.3).

### 3.1 Parameterization of joint log-probability

We want to parameterize the joint log-probability density $\log p(c,\mathbf{y})$ over (noisy) images $\mathbf{y}\in\mathbb{R}^{d}$ and image classes $c$ using features computed by a neural network
$f\colon\mathbb{R}^{d}\mapsto\mathbb{R}^{K}$.
In classification, the class logits are parameterized as a linear function of the features

$$ $\log p_{\theta}(c|\mathbf{y})=\mathopen{}\mathclose{{}\left(\mathbf{W}f( \mathbf{y})}\right)_{c}-\mathrm{LogSumExp}_{c^{\prime}}\mathopen{}\mathclose{{ }\left(\mathopen{}\mathclose{{}\left(\mathbf{W}f(\mathbf{y})}\right)_{c^{ \prime}}}\right),$ (10) $$

with $\mathbf{W}$ a matrix of size $C\times K$ where $C$ is the number of classes. We propose to parameterize the log-probability density of the noisy image distribution as a *quadratic* function of the features

$$ $\log p_{\theta}(\mathbf{y})=-\frac{1}{2}(\mathbf{w}^{\mathrm{T}}f(\mathbf{y})) ^{2}-\log Z(\theta),$ (11) $$

where $\mathbf{w}\in\mathbb{R}^{K}$ and $Z(\theta)$ is a normalizing constant that depends only on the parameters $\theta$.
We thus have the following parameterization of the joint log-density

$$ $\log p_{\theta}(\mathbf{y},c)=-\frac{1}{2}(\mathbf{w}^{\mathrm{T}}f(\mathbf{y} ))^{2}+\mathopen{}\mathclose{{}\left(\mathbf{W}f(\mathbf{y})}\right)_{c}- \mathrm{LogSumExp}_{c^{\prime}}\mathopen{}\mathclose{{}\left(\mathopen{} \mathclose{{}\left(\mathbf{W}f(\mathbf{y})}\right)_{c^{\prime}}}\right)-\log Z (\theta).$ (12) $$

Finally, the log-density of noisy images $\mathbf{y}$ conditioned on the class $c$ can be simply accessed with
$\log p_{\theta}(\mathbf{y}|c)=\log p_{\theta}(\mathbf{y},c)-\log p_{\theta}(c)$,
where $\log p_{\theta}(c)$ is intractable but not needed in practice, as explained in Section 2.
We chose the task heads to be as simple as possible, being respectively linear (for classification) and quadratic (for denoising) in the features. Preliminary experiments showed that additional complexity did not result in improved performance.

### 3.2 GradResNet architecture

Figure: Figure 2: Left: ResNet BasicBlock with bias parameters, batch-normalization (BN) layers and ReLUs. Middle: GradResNet BasicBlock with bias-free convolutional layers, GELUs, and a single group-normalization (GN) layer. Right: Illustration of the proposed side connections.
Refer to caption: extracted/5895196/figures/blocks.png

We now specify the architecture of the neural network $f_{\theta}$. As discussed in Section 2, realizing the potential of the joint modeling approach requires that the modeling bias is negligible, or in other words, that the inductive biases of the architecture and training algorithm are well-matched to the data distribution.
Fortunately, we can rest on more than a decade of research on best architectures for image classification and denoising. Architectures for these two tasks are however quite different, and the main difficulty lies in unifying them: in particular, we want the computational graph of the *gradient* of a classifier network to be structurally similar to a denoising network.

In a recent work, Hurault et al. () presented a gradient-based denoiser for Plug-and-Play image restoration, and they found that “directly modeling [the denoiser] as [the gradient of] a neural network (e.g., a standard network used for classification) leads to poor denoising performance”.
To remedy this problem, we thus propose the following architectural modifications on a ResNet18 backbone:

Smooth activation function: Cohen et al. () first proposed to use the gradient of a feedforward neural network architecture as an image denoiser for Plug-and-Play image restoration.
They write “an important design choice is that all activations are continuously differentiable and smooth functions”.
We thus replace ReLUs with smooth GELUs, following recent improvements to the ResNet architecture (Liu et al., ).

Normalization: Batch-normalization (Ioffe & Szegedy, ) is a powerful optimization technique, but its major drawback is that it has different behaviors in train and eval modes, *especially for the backward pass*.
We hence replace batch-normalizations with group-normalizations (Wu & He, ), leading to a marginal decrease in classification performance on ImageNet (Wu & He, ).
Moreover, we found that reducing the number of normalization layers is beneficial for denoising performance.
While ResNets apply a normalization after each convolutional layer,
we apply a group-normalization at the end of each basic block (see Figure 2).

Bias removal: Mohan et al. () have shown that removing all bias parameters in CNN denoisers enable them to generalize across noise levels outside their training range.
We decide to adopt this modification, removing all biases of convolutional, linear, and group-norm layers.

Mimicking skip connections:
The computational graph of the gradient of a feedforward CNN can be viewed as a UNet, where the forward pass corresponds to the encoder (reducing image resolution), and the backward pass corresponds to the decoder (going back to the input domain).
Zhang et al. () show that integrating residual connections in the UNet architecture is beneficial for denoising performance.
In order to emulate these residual connections in our gradient denoiser, we add side connections to our ResNet as illustrated in Figure 2 c).

With all these modification, we end up with a new architecture that we name GradResNet, which is still close to the original ResNet architecture.
As we will show in the numerical experiments in Section 4, this architecture retains a strong accuracy and obtains competitive denoising results.

### 3.3 Training

#### Training objectives.

Our model of the joint log-distributions $\log p_{\theta}(\mathbf{y},c)$ is the sum of two terms, $\log p_{\theta}(c|\mathbf{y})$ and $\log p_{\theta}(\mathbf{y})$.
Our training objective is thus naturally a sum of two losses: a cross-entropy loss for the class logits $\log p_{\theta}(c|\mathbf{y})$, and a denoising score matching loss for $\log p_{\theta}(\mathbf{y})$. Both objectives are integrated over noise levels $\sigma$. For simplicity, we do not add any relative weighting of the classification and denoising objectives. Our final training loss is thus

$$ $\ell(\theta)=\mathbb{E}\mathopen{}\mathclose{{}\left[-\log p_{\theta}(c| \mathbf{y})+{\mathopen{}\mathclose{{}\left\lVert\sigma\nabla_{\mathbf{y}}\log p _{\theta}(\mathbf{y})+\boldsymbol{\epsilon}}\right\rVert}^{2}}\right],$ (13) $$

where the expectation is over $(\mathbf{x},c)\sim p(\mathbf{x},c)$, $\boldsymbol{\epsilon}\sim\mathcal{N}(0,\mathrm{Id})$, and $\sigma\sim p(\sigma)$ (described below).
The main advantage of the joint learning framework is that the two tasks (modeling $p(\mathbf{x})$ and $p(c|\mathbf{x})$) naturally combine in a single task (modeling $p(\mathbf{x},c)$), thus removing the need for tuning a Lagrange multiplier trading off the two losses (where we interpret the denoising objective as a lower-bound on the negative-log-likelihood (Song et al., )).
Finally, we note that although redundant, one can also add a conditional denoising objective ${\mathopen{}\mathclose{{}\left\lVert\sigma\nabla_{\mathbf{y}}\log p_{\theta}(
\mathbf{y}|c)+\boldsymbol{\epsilon}}\right\rVert}^{2}$, or use it to replace the unconditional denoising objective. We have empirically found no difference between these choices.
Full experimental details can be found in Appendix A.

#### Training distributions.

Data augmentation is used in both image classification and image denoising to reduce overfitting, but with different augmentation strategies.
On the one hand, state of the art image classification models, e.g. Liu et al. (), are trained with the sophisticated MixUp (Zhang et al., ) and CutMix (Yun et al., ) augmentations which significantly improve classification performance but introduce visual artifacts and thus lead to non-natural images.
On the other hand, state-of-the-art denoisers like Restormer (Zamir et al., ) or Xformer (Zhang et al., ) use simple data-augmentation techniques like random image crops (without padding) and random horizontal flips, which leave the distribution of natural images unchanged.
We thus use these different data-augmentation techniques for each objective, and thus the two terms in our objective are computed over different image distributions.
Though this contradicts the assumptions behind the joint modeling approach, we found that the additional data-augmentations on the classification objective significantly boosted accuracy without hurting denoising performance.
We also found beneficial to use different noise level distributions $p(\sigma)$ for the two tasks. In both cases, $\sigma$ is distributed as the square of a uniform distribution, with $\sigma_{\min}=1$ and $\sigma_{\max}=100$ for denoising but $\sigma_{\max}=20$ for classification (relative to image pixel values in $[0,255]$). On the ImageNet dataset, for computational efficiency, we set the image and batch sizes for the denoising objective according to a schedule following Zamir et al. (), explicited in Appendix A.

## 4 Numerical results

**Table 1: CIFAR-10 experimental results. Training time is measured on a single NVIDIA A100 GPU, except for JEM, whose results and training time are taken from Grathwohl et al. (). Best results are highlighted in bold for each category of models.**
| Task | Architecture | Accuracy (%) | PSNRσ=15 | PSNRσ=25 | PSNRσ=50 | Training time (h) |
| --- | --- | --- | --- | --- | --- | --- |
| Classification | ResNet18 | $\mathbf{96.5}$ | N.A. | N.A. | N.A. | $\mathbf{0.7}$ |
| GradResNet | $96.1$ | N.A. | N.A. | N.A. | $\mathbf{0.7}$ |  |
| Denoising | DnCNN | N.A. | $32.05$ | $29.07$ | $25.23$ | $\mathbf{0.8}$ |
| DRUNet | N.A. | $32.12$ | $29.20$ | $\mathbf{25.52}$ | $0.9$ |  |
| GradResNet | N.A. | $\mathbf{32.21}$ | $\mathbf{29.28}$ | $25.51$ | $1.3$ |  |
| Joint | JEM (WideResNet) | $92.9$ | N.A. | N.A. | N.A. | $36$ |
| GradResNet | $\mathbf{96.3}$ | $31.90$ | $29.00$ | $25.25$ | $\mathbf{1.3}$ |  |

**Table 2: ImageNet experimental results. Training time is measured on a single NVIDIA A100 GPU.**
| Task | Architecture | Accuracy (%) | PSNRσ=15 | PSNRσ=25 | PSNRσ=50 | Training time (h) |
| --- | --- | --- | --- | --- | --- | --- |
| Classification | ResNet18 | $69.8$ | N.A. | N.A. | N.A. | $96$ |
| Joint | GradResNet | $68.6$ | $34.59$ | $31.94$ | $27.17$ | $208$ |

### 4.1 Classification and denoising via joint modeling

With the proposed joint modeling framework, we can perform classification and denoising at the same time.
Training and implementation details are given in Section 3 and Appendix A.
We measure the classification accuracy and the denoising PSNR averaged over the test set, compared with baselines.
The classification baseline is a standard ResNet18 (He et al., ). As denoising baselines, we use two standard architectures, DnCNN (Zhang et al., ) and DRUNet (Zhang et al., ). All baselines are trained with the same setup as our joint approach (but on a single objective).

Results are shown in Table 1 for CIFAR-10 (Krizhevsky et al., ) and in Table 2 for ImageNet (Russakovsky et al., ). We obtain classification and denoising performances that are competitive with the baselines.
Importantly, our method provides a big computational advantage to the previous work JEM (Grathwohl et al., ), as can be seen from the training times in Table 1. JEM is based on maximum-likelihood training, which is very challenging to scale in high dimensions (as the authors of note, “training […] can be quite unstable”), and therefore has been limited to $32\times 32$-sized images, even in subsequent work (Yang et al., ). In contrast, denoising score matching is a straightforward regression, which leads to a stable and lightweight training that scales much more easily to ImageNet at full $224\times 224$ resolution.

In Table 1, we report results for GradResNet trained on a single task to separate the impact of each objective. We remark that the denoising objective *improves* classification performance, confirming the arguments in Section 2.1. The classification objective however slightly degrades denoising performance. We also conduct several ablation experiments to validate our architecture choices in Table 3 in Appendix B. All our choices are beneficial for both classification and denoising performance, except for the removal for biases which very slightly affects denoising performance.

Figure: Figure 3: Denoising experiment. Top, left-to-right: Original CIFAR-10 test image, noisy image ($\sigma=50$), denoised images with unconditional and conditional denoisers, and difference between them (magnified $500$x). Bottom, left-to-right: Eigenvectors corresponding to the three largest ($2.71$,$2.16$, $2.03$) and two lowest ($2.8\times{10}^{-5}$,$-1.9\times{10}^{-5}$) magnitude eigenvalues of the unconditional denoiser Jacobian. More examples are shown in Appendix C.
Refer to caption: extracted/5895196/figures/denoiser_boat.png

### 4.2 Analyzing the learned denoisers

On the top row of Figure 3, we show an example of a noisy image denoised using the learned unconditional and class-conditional denoisers. We also show the difference between the two denoised images scaled by a factor of $500$.
The two denoised images look very similar, suggesting that the class conditioning is not very informative here.

Importantly, as we removed all the bias terms from the convolutional layers, our denoisers are bias-free.
Mohan et al. () have shown that bias-free deep denoisers $\mathcal{D}$ are locally linear operators, i.e.,
$\mathcal{D}(\mathbf{y})=\nabla_{\mathbf{y}}\mathcal{D}(\mathbf{y})\mathbf{y}$,
where $\nabla_{\mathbf{y}}\mathcal{D}(\mathbf{y})$ is the Jacobian of the denoiser evaluated at $\mathbf{y}$.
To study the effect of a denoiser on a noisy image $\mathbf{y}$, one can compute the singular value decomposition of the denoiser’s Jacobian evaluated at $\mathbf{y}$ (see Mohan et al. () for details).
The Jacobian of our unconditional denoiser is

$$ $\nabla_{\mathbf{y}}\mathcal{D}_{\rm u}(\mathbf{y})=\text{Id}+\sigma^{2}\nabla^ {2}_{\mathbf{y}}\log p_{\theta}(\mathbf{y}),$ (14) $$

where $\nabla^{2}$ denotes the Hessian. Since our denoiser is a gradient field, its Jacobian is symmetric, and can thus be diagonalized.
The bottom row of Figure 3 shows the eigenvectors corresponding to the three largest and two lowest magnitude eigenvalues.
Interestingly, eigenvectors corresponding to largest eigenvalues capture large scale features from the original image which are amplified by the denoiser.
Conversely, lowest eigenvectors correspond to noisy images without shape nor structure that are discarded by the denoiser.

Figure: Figure 4: Adversarial attacks on CIFAR-10 test set. The baseline is a ResNet18 trained for classification only, ours is a GradResNet trained for classification and denoising, and JEM is the method proposed by Grathwohl et al. (). Left: $\ell^{\infty}$ PGD attack. Right: $\ell^{2}$ PGD attack.
Refer to caption: extracted/5895196/figures/linf_ours_JEM.png

### 4.3 Adversarial robustness

In their seminal work on joint-modeling, Grathwohl et al. () show that learning the joint distribution over images and classes leads to increased robustness to adversarial attacks.
We perform projected gradient descent (PGD) adversarial attacks using the foolbox library (Rauber et al., ) on our baseline classifier and the classifier optimized for joint-modeling.
Results are shown in Figure 4.
We note that the proposed method increases adversarial robustness, but not as much as an MCMC-trained joint energy-based model (Grathwohl et al., ).

## 5 Discussion and related work

### 5.1 Robust classifiers

#### Adversarial robustness.

Adversarial robustness is deeply related to noise addition. Indeed, Gu & Rigazio () have shown that adding noise to adversarial attacks (referred to as *randomized smoothing*) can mitigate their effect. Further, Lecuyer et al. () and follow-ups (Li et al., ; Cohen et al., ) showed that being robust to additive noise provably results in adversarial robustness using this strategy. This was recently shown to be practical in Maho et al. (). Note that noise addition *at test time* (as opposed to only during training) is critical to obtain robustness (Carlini & Wagner, ), an observation also made in Su & Kempe (). This appears in the instability of the $\sigma\to 0$ limit in eq. 9, and indicates that robustness tests as in Figure 4 should be computed over attack strength *and* noise levels.

Building classifiers that are robust to additive noise on the input image was considered in many works (note that this is separate from the issue of learning from noisy labels). Dodge & Karam () found that fine-tuning standard networks on noisy images improve their robustness, but still falls short of human accuracy at large noise levels. A common benchmark (which also include corruptions beyond additive noise) was established in Hendrycks & Dietterich (). Effective approaches include carefully designing pooling operators (Li et al., ) and iterative distillation (Xie et al., ).

#### Adversarial gradients and generative models.

Several works use denoisers or other generative models to improve adversarial or noise robustness, e.g., by denoising input images as a pre-processing step (Roy et al., ), or by leveraging an off-the-shelf generative model to detect and “purify” adversarial examples (Song et al., ).
Grathwohl et al. () unified the generative model and the classifier in a single model and showed that joint modeling results in increased adversarial robustness.
Our work goes one step further by also making the connection to noise robustness and denoising through diffusion models, warranting further work in this direction.

### 5.2 Sampling and architecture of gradient denoisers

#### Gradient denoiser architectures.

Several works have studied the question of learning the score as a gradient. Most similar to our setup is Cohen et al. (), where the authors introduce the GraDnCNN architecture. When modeling directly the score with a neural network, Saremi () show that the learned score is not a gradient field unless under very restrictive conditions. Nonetheless, Mohan et al. () show that the learned score is approximately conservative (i.e., a gradient field), and Chao et al. () introduce an additional training objective to penalize the non-conservativity. Finally, Horvat & Pfister () demonstrate that the non-conservative component of the score is ignored during sampling with the backward diffusion, though they find that a conservative denoiser is necessary for other tasks such as dimensionality estimation. Our work provides several recommendations for the design of gradient-based denoisers.

#### Sampling.

Preliminary experiments indicate that sampling from the distributions $p(\mathbf{x})$ and $p(\mathbf{x}|c)$ learned by our model, e.g. with DDPM (Ho et al., ), is not on par with standard diffusion models. Salimans & Ho () noted that “specifying the score model by taking the gradient of an image classifier has so far not produced competitive results in image generation.”
While our changes to the ResNet architecture significantly alleviate these issues, its gradient might not have the right inductive biases to model the score function.
Indeed, recent works (Salimans & Ho, ; Hurault et al., ; Yadin et al., ) rather model log-probabilities with (the squared norm of) a UNet, whose gradient is then more complicated (its computational graph is *not* itself a UNet). Understanding the inductive biases of these different approaches is an interesting direction for future work.
After the completion of this work, we became aware of a related approach by (Guo et al., ). They tackle classification and denoising with a UNet network, and demonstrate competitive sampling results. This complements our conceptual arguments for the joint approach, confirms its potential, and calls for an explanation between the discrepancies in performance between the two architectures.

#### Conditioning.

We also note that the class information is used differently in classification and conditional denoising. On the one hand, in classification, the class label is only used as an index in the computed logits (which allows for fast evaluation of all class logits). On the other hand, conditional denoisers typically embed the class label as a continuous vector, which is then used to modify gain and bias parameters in group-normalization layers (which is more expressive). This raises the question whether these two different approaches could be unified in the joint framework.
An area where we expect the joint approach to lead to significant advances is in that of caption conditioning, where the classifier $\log p(c|\mathbf{y})$ is replaced by a captioning model. Training a *single* model on *both* objectives has the potential to improve the correspondence between generated images and the given caption.
Another type of conditioning is with the noise level $\sigma$, also known as the time parameter $t$.
In a recent work, Yadin et al. () propose classification diffusion models (CDM). They model the joint distribution over images and discrete noise levels with denoising score matching and noise level classification. Both approaches are orthogonal and could be combined in future work.

## 6 Conclusion

In this paper, we have shown that several machine-learning tasks and issues are deeply connected: classification, denoising, generative modeling, adversarial robustness, and conditioning are unified by our joint modeling approach.
Our method is significantly more efficient than previous maximum-likelihood approaches, and we have shown numerical experiments which give promising results on image (robust) classification and image denoising, though not yet in image generation.

We believe that exploring the bridges between these problems through the lens of joint modeling as advocated in this paper are fruitful research directions.
For instance, can we understand the different inductive biases of ResNet and UNet architectures in the context of joint energy-based modeling? Can we leverage the connection between adversarial gradients and denoising to further improve classifier robustness?
We also believe that the joint approach holds significant potential in the case where the class label $c$ is replaced by a text caption. Indeed, modeling the distribution of captions $p(c)$ is highly non-trivial and should be beneficial to conditional generative models for the same reasons than we used to motivate generative classifiers in Section 2.1.
Finally, the joint approach yields a model of the log-probability $\log p(\mathbf{y})$, as opposed to the score $\nabla_{\mathbf{y}}\log p(\mathbf{y})$. We thus expect that this model could be used to empirically probe properties of high-dimensional image distributions.

## Appendix A Training and implementation details

#### Experiments on CIFAR-10.

We implement the proposed network and the training script using the PyTorch library (Paszke et al., ).
We adapt the original ResNet18 (He et al., ) to $32\times 32$ images by setting the kernel size of the first convolutional layer to $3$ (originally $7$) and the stride of the first two convolutional layers to $1$. We also remove the max-pooling layer.
To train our GradResNet, we use the AdamW optimizer with the default parameters except for the weight decay ($0.05$) and the learning rate ($3\times{10}^{-4}$).
We use a cosine annealing schedule for the learning rate, without warm-up.
We use a batch size of $64$ for denoising and $128$ for classification.
The optimized loss is the sum of the cross-entropy loss and the mean-squared denoising objective (eq. 13).
We run the optimization for $78$k iterations, corresponding to $200$ epochs for classification.

For classification, we use for data-augmentation random horizontal flips, padded random crops with padding of $4$ pixels, and MixUp (Zhang et al., ) and CutMix (Yun et al., ) as implemented in torchvision.transforms with the default parameters.
We also add Gaussian white noise scaled by $\sigma$ that we draw from a squared uniform distribution in the range $[0,20]$.
For denoising, we simply use random flips.
We add Gaussian noise with $\sigma\in\mathopen{}\mathclose{{}\left[1,100}\right]$.

#### Experiments on ImageNet.

We use the standard ResNet18 architecture, but without the max-pooling layer.
We set the learning rate to $2\times{10}^{-4}$ and weight decay to ${10}^{-4}$. We train the network for $400$ epochs with a batch size of $512$ for classification. We replace the random crop data augmentation with random resized crops of size $224\times 224$.
For denoising, we gradually change the image size and batch size across training, following Zamir et al. (). That is, we compute the denoising loss over image batches of size $64\times 128\times 128$ until epoch $150$, then $40\times 160\times 160$ until epoch $260$, then $32\times 192\times 192$ until epoch $340$, and $16\times 224\times 224$ until epoch $400$. Smaller images are extracted by taking random crops of the chosen size.
Both objectives are computed with Gaussian noise with $\sigma$ the square of a uniform distribution supported in $[1,70]$.
All other hyperparameters are the same as for the CIFAR-10 dataset.

## Appendix B Ablation experiments

We present ablation experiments to validate our architecture choices of Section 3.2 in Table 3. Namely, we replace the GeLU non-linearity with the original ReLU, replace GroupNorm layers with the original BatchNorm, add biases to convolutional and GroupNorm layers, or remove side connections (see Figure 2).

**Table 3: Ablation experiments on CIFAR-10 dataset.**
| Task | Architecture | Accuracy (%) | PSNRσ=15 | PSNRσ=25 | PSNRσ=50 |
| --- | --- | --- | --- | --- | --- |
| Joint | GradResNet | $\mathbf{96.3}$ | $31.90$ | $29.00$ | $25.25$ |
| (ReLU) | $92.0$ | $29.59$ | $24.90$ | $17.11$ |  |
| (BatchNorm) | $11.9$ | $24.33$ | $20.84$ | $18.06$ |  |
| (Biases) | $95.9$ | $\mathbf{31.95}$ | $\mathbf{29.03}$ | $\mathbf{25.30}$ |  |
| (No side co.) | $94.0$ | $31.86$ | $28.95$ | $25.17$ |  |

## Appendix C Denoising experiments

Additional denoising experiments are presented in Figure 5.

Figure: Figure 5: Additional denoising experiments with $\sigma=50$. See Figure 3 for details.
Refer to caption: extracted/5895196/figures/denoiser_horse.png

## Appendix D Bias-variance decomposition of the generalization error

We sketch a derivation of the results. They can be rigorously proved under usual regularity conditions by a straightforward generalization of the proofs of asymptotic consistency, efficiency, and normality of the maximum-likelihood estimator (see, e.g., Hogg et al. (, Thereom 6.2.2)).

Given a function $\ell$, a probability distribution $p(\mathbf{x})$, and i.i.d. samples $\mathbf{x}_{1},\dots,\mathbf{x}_{n}$, consider the minimization problems

$$ $\displaystyle\theta_{\star}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \mathbb{E}\mathopen{} \mathclose{{}\left[\ell(\theta,\mathbf{x})}\right],$ $\displaystyle\theta_{n}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \frac{1}{n}\sum_{i=1}^{n}\ell (\theta,\mathbf{x}_{i}).$ (15) $$

We wish to estimate the fluctuations of the random parameters $\theta_{n}$ around the deterministic $\theta_{\star}$ when $n\to\infty$.

The estimator $\theta_{n}$ is defined by

$$ $\frac{1}{n}\sum_{i=1}^{n}\nabla_{\theta}\ell(\theta_{n},\mathbf{x}_{i})=0.$ (16) $$

A first-order Taylor expansion around $\theta_{\star}$ gives

$$ $\frac{1}{n}\sum_{i=1}^{n}\nabla_{\theta}\ell(\theta_{\star},\mathbf{x}_{i})+ \frac{1}{n}\sum_{i=1}^{n}\nabla^{2}_{\theta}\ell(\theta_{\star},\mathbf{x}_{i} )(\theta_{n}-\theta_{\star})=0,$ (17) $$

and thus

$$ $\theta_{n}=\theta_{\star}-\frac{1}{\sqrt{n}}\mathopen{}\mathclose{{}\left( \frac{1}{n}\sum_{i=1}^{n}\nabla^{2}_{\theta}\ell(\theta_{\star},\mathbf{x}_{i} )}\right)^{-1}\mathopen{}\mathclose{{}\left(\frac{1}{\sqrt{n}}\sum_{i=1}^{n} \nabla_{\theta}\ell(\theta_{\star},\mathbf{x}_{i})}\right).$ (18) $$

By applying the law of large numbers to the first sum and the central limit theorem to the second sum (by definition of $\theta_{\star}$, $\mathbb{E}\mathopen{}\mathclose{{}\left[\nabla_{\theta}\ell(\theta_{\star},
\mathbf{x})}\right]=0$), it follows that as $n\to\infty$ we have

$$ $\theta_{n}\sim\mathcal{N}\mathopen{}\mathclose{{}\left(\theta_{\star},\frac{1} {n}\Sigma}\right),$ (19) $$

with a covariance

$$ $\displaystyle\Sigma=\mathbb{E}\mathopen{}\mathclose{{}\left[\nabla^{2}_{\theta }\ell(\theta_{\star},x)}\right]^{-1}\,\mathrm{Cov}\mathopen{}\mathclose{{} \left[\nabla_{\theta}\ell(\theta_{\star},\mathbf{x})}\right]\,\mathbb{E} \mathopen{}\mathclose{{}\left[\nabla^{2}_{\theta}\ell(\theta_{\star},x)}\right ]^{-1}.$ (20) $$

For the generative and discriminative modeling tasks, we have

$$ $\displaystyle\theta_{\star}^{\mathrm{gen}}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \mathbb{E}\mathopen{} \mathclose{{}\left[-\log p_{\theta}(\mathbf{x},c)}\right],$ $\displaystyle\theta_{n}^{\mathrm{gen}}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \frac{1}{n}\sum_{i=1}^{n}- \log p_{\theta}(\mathbf{x}_{i},c_{i}),$ (21) $\displaystyle\theta_{\star}^{\mathrm{dis}}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \mathbb{E}\mathopen{} \mathclose{{}\left[-\log p_{\theta}(c|\mathbf{x})}\right],$ $\displaystyle\theta_{n}^{\mathrm{dis}}$ $\displaystyle=\operatorname*{arg\,min}_{\theta}\ \frac{1}{n}\sum_{i=1}^{n}- \log p_{\theta}(c_{i}|\mathbf{x}_{i}).$ (22) $$

In this setting, eq. 20 yields

$$ $\displaystyle\Sigma^{\mathrm{gen}}$ $\displaystyle=\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p _{\theta_{\star}^{\mathrm{gen}}}(\mathbf{x},c)}\right]^{-1}\,\mathrm{Cov} \mathopen{}\mathclose{{}\left[-\nabla_{\theta}\log p_{\theta_{\star}^{\mathrm{ gen}}}(\mathbf{x},c)}\right]\,\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^ {2}_{\theta}\log p_{\theta_{\star}^{\mathrm{gen}}}(\mathbf{x},c)}\right]^{-1},$ (23) $\displaystyle\Sigma^{\mathrm{dis}}$ $\displaystyle=\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p _{\theta_{\star}^{\mathrm{dis}}}(c|\mathbf{x})}\right]^{-1}\,\mathrm{Cov} \mathopen{}\mathclose{{}\left[-\nabla_{\theta}\log p_{\theta_{\star}^{\mathrm{ dis}}}(c|\mathbf{x})}\right]\,\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^ {2}_{\theta}\log p_{\theta_{\star}^{\mathrm{dis}}}(c|\mathbf{x})}\right]^{-1}.$ (24) $$

Note that we do not recover the Fisher information since expected values are with respect to the true distribution $p$, which is different from $p_{\theta_{\star}^{\mathrm{gen}}}$ and $p_{\theta_{\star}^{\mathrm{dis}}}$ under model misspecification.

These expressions can be plugged in a second-order Taylor expansion of the KL divergence: for any $\theta_{n}$ asymptotically normally distributed around $\theta_{\star}$ with covariance $\frac{1}{n}\Sigma$,

$$ $\displaystyle\mathbb{E}\mathopen{}\mathclose{{}\left[\operatorname{KL} \mathopen{}\mathclose{{}\left(p(c|\mathbf{x})\,\middle\|\,p_{\theta_{n}}(c| \mathbf{x})}\right)}\right]={}$ $\displaystyle\underbrace{\mathbb{E}\mathopen{}\mathclose{{}\left[\operatorname {KL}\mathopen{}\mathclose{{}\left(p(c|\mathbf{x})\,\middle\|\,p_{\theta_{\star }}(c|\mathbf{x})}\right)}\right]}_{b}$ $\displaystyle{}+\frac{1}{2n}\underbrace{\operatorname{Tr}\mathopen{}\mathclose {{}\left(\Sigma\,\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta} \log p_{\theta_{\star}}(c|\mathbf{x})}\right]}\right)}_{v}{}+o\mathopen{} \mathclose{{}\left(\frac{1}{n}}\right).$ (25) $$

Finally, we obtain

$$ $\displaystyle b^{\mathrm{gen}}$ $\displaystyle=\mathbb{E}\mathopen{}\mathclose{{}\left[\operatorname{KL} \mathopen{}\mathclose{{}\left(p(c|\mathbf{x})\,\middle\|\,p_{\theta_{\star}^{ \mathrm{gen}}}(c|\mathbf{x})}\right)}\right],$ $\displaystyle v^{\mathrm{gen}}$ $\displaystyle=\operatorname{Tr}\mathopen{}\mathclose{{}\left(\Sigma^{\mathrm{ gen}}\,\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{ \theta_{\star}^{\mathrm{gen}}}(c|\mathbf{x})}\right]}\right),$ (26) $\displaystyle b^{\mathrm{dis}}$ $\displaystyle=\mathbb{E}\mathopen{}\mathclose{{}\left[\operatorname{KL} \mathopen{}\mathclose{{}\left(p(c|\mathbf{x})\,\middle\|\,p_{\theta_{\star}^{ \mathrm{dis}}}(c|\mathbf{x})}\right)}\right],$ $\displaystyle v^{\mathrm{dis}}$ $\displaystyle=\operatorname{Tr}\mathopen{}\mathclose{{}\left(\Sigma^{\mathrm{ dis}}\,\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{ \theta_{\star}^{\mathrm{dis}}}(c|\mathbf{x})}\right]}\right).$ (27) $$

By definition of $\theta_{\star}^{\mathrm{dis}}$, we have $b^{\mathrm{dis}}\leq b^{\mathrm{gen}}$ (since maximizing likelihood is equivalent to minimizing KL divergence). The variance terms can be compared when the model is well-specified, i.e., there exists $\theta_{\star}$ such that $p=p_{\theta_{\star}}$. In this case, we have $\theta_{\star}^{\mathrm{gen}}=\theta_{\star}^{\mathrm{dis}}=\theta_{\star}$, so that $b^{\mathrm{gen}}=b^{\mathrm{dis}}=0$, and the variances simplify to

$$ $\displaystyle v^{\mathrm{gen}}=\operatorname{Tr}\mathopen{}\mathclose{{}\left( \mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{\theta_{ \star}}(\mathbf{x},c)}\right]^{-1}\,\mathbb{E}\mathopen{}\mathclose{{}\left[- \nabla^{2}_{\theta}\log p_{\theta_{\star}}(c|\mathbf{x})}\right]}\right)\leq m,$ (28) $\displaystyle v^{\mathrm{dis}}=\operatorname{Tr}\mathopen{}\mathclose{{}\left( \mathrm{Id}}\right)=m,$ (29) $$

using the Fisher information relationship

$$ $\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{\theta_{ \star}}(c|\mathbf{x})}\right]=\mathrm{Cov}\mathopen{}\mathclose{{}\left[- \nabla_{\theta}\log p_{\theta_{\star}}(c|\mathbf{x})}\right],$ (30) $$

and the decomposition

$$ $\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{\theta_{ \star}}(\mathbf{x},c)}\right]=\mathbb{E}\mathopen{}\mathclose{{}\left[-\nabla^ {2}_{\theta}\log p_{\theta_{\star}}(c|\mathbf{x})}\right]+\underbrace{\mathbb{ E}\mathopen{}\mathclose{{}\left[-\nabla^{2}_{\theta}\log p_{\theta_{\star}}( \mathbf{x})}\right]}_{\succcurlyeq 0}.$ (31) $$

We thus have $v^{\mathrm{gen}}\leq v^{\mathrm{dis}}$ in the well-specified case.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: - Please see the weakness section.
soundness: 2
strengths: - The attempt to jointly classify and denoise looks interesting. One network can be effectively used for both classification and denoising.
summary: This work proposes a joint framework for classifying and denoising and also proposes a new network called GradResNet. This single network was trained for both denoising and classification tasks, yielding comparable results to the prior works such as ResNet, DnCNN and so on.
weaknesses: - It is less convincing why one needs to combine the tasks of classification and denoising into a single network. Moreover, it is unclear what are the novel contributions of this work over prior works such as JEM.
- The evaluation look simplified by using too small networks for the problem like ImageNet classification, by denoising too small images with simple synthetic noises, and by  using too limited benchmarks.
- Diffusion models were mentioned in this work, but there is no experimental results about them.

---

confidence: 5
contribution: 1
initial_rating: 1
presentation: 3
questions: Why did you ignore existing works?
soundness: 3
strengths: The authors propose a nice joint formulation for denoising and classification. The mathematical derivation is clear and the formulation is sound. If there were not many prior works that did very similar things I would have recommended accepting the paper. But a proper work should compare to prior works...
summary: The paper propose a novel architecture that perform joint denoising and classification. It relies on tools from diffusion models such that the gradient of the denoiser is used to preform classification. The proposed algorithm and architecture are interesting and the mathematical formulation is sound. The authors perform experiments comparing to existing classifiers and denoisers showing on par performance. 
Yet, the authors ignore a large body of works that already use diffusion models to perform classification and bear great similarities to the proposed work. I will detail this below.
weaknesses: The paper elegantly (or may be not) ignores all the prior works that use diffusion models to perform classification. In fact, they cite one work (your diffusion model is secretly one shot classifier) but don't compare to it. Indeed, the work they already cite, deals less with robustness but there are many other works that perform joint classification and denoising and study robustness. For example:
(CERTIFIED!!) ADVERSARIAL ROBUSTNESS FOR FREE!, ICLR 2023
Robust Classification via a Single Diffusion Model, ICML 2024
Diffusion Models are Certifiably Robust Classifiers, NeurIPS 2024

Mentioning these works, explaining the difference and comparing to them (!!!) is a must. Right now this is the main problem with the paper and by ignoring the existing prior art it is a clear reject.

---

confidence: 2
contribution: 2
initial_rating: 5
presentation: 3
questions: - Regarding the SVD decomposition of the Jacobian matrix, as described in line 427, it seems that any bias-free denoiser satisfies the condition \( D = \nabla_Y D Y \). Therefore, as long as a denoiser is effective and bias-free, the Jacobian will be decomposed to image feature information. I'm not sure what the significance of this experiment is, especially since Mohan et al. (2020) have already validated this.

-As mentioned in line 506, it seems that Guo et al. (2023) have already conducted a very similar study.


[1] Sreyas Mohan, Zahra Kadkhodaie, Eero P Simoncelli, and Carlos Fernandez-Granda. Robust and interpretable blind image denoising via bias-free convolutional neural networks. In International Conferenece on Learning Representations (ICLR), Addis Ababa, Ethiopia, April 2020.

[2] Qiushan Guo, Chuofan Ma, Yi Jiang, Zehuan Yuan, Yizhou Yu, and Ping Luo. Egc: Image generation and classification via a diffusion energy-based model. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 22952–22962, 2023.
soundness: 2
strengths: + Research on the joint learning of denoising and classification is limited; this paper highlights the potential of such integrated approaches.

+ The numerical results for classification surpass those of previous joint methods.

+ The relationship between the proposed method and the adversarial noise and energy-based models is analyzed in depth and discussed in detail.
summary: This paper integrates image denoising and image classification tasks, enabling the model to achieve enhanced robustness through joint learning. The architecture is based on ResNet-18, with modifications to improve performance by directly modeling the denoiser as the gradient of the neural network. The training objective combines cross-entropy loss with denoising score matching loss. Experimental results demonstrate that this approach outperforms previous jointly learned models and exhibits strong resilience to adversarial noise, along with a thorough analysis of its connection to score-based models.
weaknesses: - While this paper demonstrates superior performance in joint methods compared to others, it does not show significant advantages in standalone classification or denoising tasks. The denoising task under Gaussian noise can be viewed as a sampling process within a score-based diffusion model that uses Gaussian noise as a prior. In other words, the method presented in this paper sacrifices generative capabilities but learns a fixed noise-level denoiser in favor of enhanced classification performance. As a result, it outperforms JEM in classification but lacks the sampling ability of diffusion models and exhibits weaker resistance to adversarial noise compared to JEM.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 3
questions: See Weaknesses.
soundness: 3
strengths: 1. The derived discrepancy in the denoiser complements the previously connections between adversarial robustness and denoising.
2. The proposed architecture combines inductive biases suitable for both denoising and classification.
summary: This paper unifies the tasks of image classification and denoising through a joint probabilistic model of (noisy) images and class labels to address complementary issues, such as insufficient robustness and partial neglect of conditional information in each task. The paper first introduces a framework that uses a single network to parameterize the joint distribution \( p(y, c) \) for performing classification, class-conditional, and unconditional denoising. Then, an architecture is proposed to parameterize the joint log-probability density of images and labels.
weaknesses: 1. In joint training, the performance of both classification and denoising is inferior to existing standalone classification or denoising methods. 
2. Although joint training improves classification performance compared to separate training, the improvement is very limited and still falls short of ResNet18’s classification performance. 
3. The authors claim that the proposed method can be applied to out-of-distribution detection, but no experiments were conducted to verify the effectiveness of the method in this regard.

Meta-review: Reviewers agree that the paper should not be accepted in its current form, due to underperformance wrt. prior work.
Authors rebuttal did not convince the reviewers of the papers limitation. Therefore the paper is recommended for rejection.

Decision: Reject