GUIDE: Guidance-based Incremental Learning with Diffusion Models

## Abstract

Abstract We introduce GUIDE, a novel continual learning approach that directs diffusion models to rehearse samples at risk of being forgotten.
Existing generative strategies combat catastrophic forgetting by randomly sampling rehearsal examples from a generative model. Such an approach contradicts buffer-based approaches where sampling strategy plays an important role.
We propose to bridge this gap by incorporating classifier guidance into the diffusion process to produce rehearsal examples specifically targeting information forgotten by a continuously trained model. This approach enables the generation of samples from preceding task distributions, which are more likely to be misclassified in the context of recently encountered classes.
Our experimental results show that GUIDE significantly reduces catastrophic forgetting,
outperforming conventional random sampling approaches and surpassing recent state-of-the-art methods in continual learning with generative replay.

## 1 Introduction

A typical machine learning pipeline involves training a model on a static dataset and deploying it in a task with a similar data distribution. This assumption frequently proves impractical in real-world scenarios, where models encounter a constantly evolving set of objectives. To address this issue, Continual Learning (CL) methods try to accumulate knowledge from separate tasks while overcoming limited knowledge transfer and catastrophic forgetting [].
Replay-based CL strategies employ a memory buffer to retain examples from preceding tasks, which are then mixed with samples from the current task. In order for this approach to be effective, it requires a well-designed sampling strategy such as approximating the true data distribution with stored samples [, ], maximizing the diversity of samples in a buffer [],
or hard negative mining [].

Figure: Figure 1: Rehearsal sampling in GUIDE. We guide the denoising process of a diffusion model trained on the previous task (blue) toward classes from the current task (orange). The replay samples, highlighted with blue borders, share features with the examples from the current task, which may be related to characteristics such as color or background (e.g., fishes on a snowy background when guided to snowmobile). Generative rehearsal on such samples positioned near the classifier’s decision boundary successfully mitigates catastrophic forgetting.
Refer to caption: extracted/5634821/Figures/teaser_imagenet.png

Despite offering decent performance, these methods are unsuitable for certain applications, e.g., due to limited scalability, memory constraints, or privacy restrictions.
To mitigate this issue, Shin et al. [] introduced Deep Generative Replay (DGR) that substitutes the memory buffer with a Generative Adversarial Networks (GAN) [],
which was later extended with various generative models [, , ].
Although generative rehearsal approaches mitigate the limitations of buffer-based methods, relatively little attention was paid to understanding and controlling what samples they generate, simply relying on random generations. This contradicts the importance of sampling strategies proposed for buffer-based techniques.

In this work, we propose to bridge this gap and introduce GUIDE: a new continual learning method with Denoising Deep Probabilistic Models (DDPM)  [, ]. We first demonstrate that we can use the classifier guidance technique [] to steer the backward diffusion process towards classes not present in the training set of a diffusion model. Then, additionally motivated by the finding that examples located close to the decision boundary are more likely to be forgotten [],
we guide the diffusion model trained on data from preceding tasks towards recently encountered classes in generative rehearsal scenario.
The visualization of this idea is presented in Fig. 1.

In our experiments, we show that rehearsal with GUIDE
outperforms other state-of-the-art generative replay methods, significantly reducing catastrophic forgetting in class-incremental learning.
On top of our method, we thoroughly evaluate several alternative guidance strategies that generate rehearsal samples of diverse characteristics.
Our contributions can be summarized as follows:

- •
We introduce GUIDE - generative replay method that benefits from classifier guidance to generate rehearsal data samples prone to be forgotten.
- •
We demonstrate that incorporating classifier guidance enables the generation of high-quality samples situated near task decision boundaries. This approach effectively mitigates forgetting in class-incremental learning.
- •
We show the superiority of GUIDE over recent state-of-the-art generative rehearsal approaches and provide an in-depth experimental analysis of our method’s main contribution.

## 2 Related work

### 2.1 Continual Learning

Continual learning methods aim to mitigate catastrophic forgetting – a phenomenon where deep neural networks trained on a sequence of tasks completely and abruptly forget previously learned information upon retraining on a new task. Recent methods can be organized into three main families. Regularization methods [, , ] identify the most important parameters and try to slow down their changes through regularization. Architectural approaches [, , , ] change the structure of the model for each task. Rehearsal methods replay data samples from previous tasks and train the model on a combination of data samples from previous and current tasks. In the most straightforward rehearsal approach, a memory buffer is used to store exemplars from previous tasks [, , , , , , ].
Some methods, instead of directly using exemplars, stores data representations from previous tasks in different forms, e.g., *mnemonics* - optimized artificial samples [], distilled datasets [, , ], or addressable memory structure [].

#### Continual learning with generative rehearsal

Because of the limitations of buffer-based approaches related to the constantly growing memory requirements and privacy issues,
Shin et al. [] introduce Deep Generative Replay, where a GAN is used to generate rehearsal samples from previous tasks for the continual training of a classifier.
A similar approach is further extended to different model architectures like Variational Autoencoders (VAE) [, ], normalizing flows [] or Gaussian Mixture Models [].

On top of those baseline approaches, Ramapuram et al. [] introduce a method that benefits from the knowledge distillation technique in VAE training in CL setup, while Wu et al. [] introduce Memory Replay GANs (MeRGANs) and describe two approaches to prevent forgetting - by joint retraining and by aligning the replay samples.

Instead of replaying images, several approaches propose to rehearse internal data representations instead, e.g.,
Brain-Inspired Replay (BIR) [] with an extension to Generative Feature Replay (GFR) [], where the rehearsal is combined with features distillation. Kemker and Kanan [] divide feature rehearsal into short and long-term parts.

### 2.2 Guided image generation in diffusion models

Besides conditioning, controlling diffusion model outputs can be achieved by modifying the process of sampling that incorporates additional signals from the guidance function. Classifier guidance introduced by Dhariwal and Nichol [] employ a trained classifier model to steer the generation process via gradients of a specified loss function, typically assessing the alignment of generated images with specific classes.
This concept is extended by Bansal et al. [] to include any off-the-shelf model in guidance and further applied by Augustin et al. [] for explaining the decisions of the classifier with generated counterfactual examples. Contrasting with these methods,
Epstein et al. [] introduce self-guidance based on the internal representations of the diffusion model, while Ho and Salimans [] introduce classifier-free guidance, achieving results akin to classifier-based approaches by joint training of unconditional and conditional diffusion models.

### 2.3 Continual learning with diffusion models

Diffusion models excel in generative tasks, surpassing VAEs [] and GANs, yet their adoption in CL remains limited.
Deep Diffusion-based Generative Replay (DDGR) [] uses a diffusion model in a generative rehearsal method and benefits from a classifier pretrained on previous tasks to synthesize high-quality replay samples. Class-Prototype Conditional Diffusion Model (CDPM) [] further enhances the replay samples quality by conditioning the diffusion model on learnable class-prototypes.
In this work, we further extend those ideas and show that classifier guidance might be used not only to generate high-quality samples but also to introduce the desired characteristics of rehearsal samples.

## 3 Background

### 3.1 Diffusion models

Let $q(\mathbf{x}_{0})$ be the real data distribution. The forward diffusion process $q$ gradually adds Gaussian noise to each data sample $\mathbf{x}_{0}\sim q(\mathbf{x}_{0})$ over a sequence of $T$ steps according to the variance schedule $\{\beta_{t}\in(0,1)\}_{t=1}^{T}$. If we additionally define $\alpha_{t}=1-\beta_{t}$ and $\bar{\alpha}_{t}=\prod_{i=1}^{t}\alpha_{i}$, then:

$$ $q(\mathbf{x}_{t}|\mathbf{x}_{t-1})=\mathcal{N}(\mathbf{x}_{t};\sqrt{\alpha_{t} }\mathbf{x}_{t-1},(1-\alpha_{t})\mathbf{I}).$ (1) $$

This process produces a sequence of noisy samples $\mathbf{x}_{1},\dots,\mathbf{x}_{T}$, where $\mathbf{x}_{T}$ is pure Gaussian noise.
The reverse diffusion process $p$ can be modeled as a diagonal Gaussian:

$$ $p_{\theta}(\mathbf{x}_{t-1}|\mathbf{x}_{t})=\mathcal{N}(\mathbf{x}_{t-1};\mu_{ \theta}(\mathbf{x}_{t},t),\Sigma_{\theta}(\mathbf{x}_{t},t)),$ (2) $$

where $\mu_{\theta}(\mathbf{x}_{t},t)$ can be parameterized by a deep neural network $\epsilon_{\theta}(\mathbf{x}_{t},t)$ with parameters $\theta$ that predicts the added noise $\epsilon_{t}$ for each noise level $t$:

$$ $\mu_{\theta}(\mathbf{x}_{t},t)=\frac{1}{\sqrt{\alpha_{t}}}\left(\mathbf{x}_{t} -\frac{1-\alpha_{t}}{\sqrt{1-\bar{\alpha}_{t}}}\epsilon_{\theta}(\mathbf{x}_{t },t)\right).$ (3) $$

Sampling from DDPM requires denoising the sample sequentially from $\mathbf{x}_{T}\sim\mathcal{N}(0,\mathbf{I})$ $T$ steps up until $\mathbf{x}_{0}$. In this work, we benefit from the speed-up technique known as Denoising Diffusion Implicit Models (DDIM) introduced by Song et al. [], where at each time step $t$, we first predict the denoised sample at $t=0$:

$$ $\hat{\mathbf{z}}_{0}(\mathbf{x}_{t})=\frac{\mathbf{x}_{t}-\sqrt{1-\bar{\alpha} _{t}}\epsilon_{\theta}(\mathbf{x}_{t},t)}{\sqrt{\bar{\alpha}_{t}}},$ (4) $$

then we calculate $\mathbf{x}_{t-1}$ based on this prediction. This allows us to sample using fewer steps in the reverse process, reducing the inference time significantly.

### 3.2 Classifier guidance

Classifier guidance [] enables steering the backward diffusion process by combining the intermediate denoising steps of conditional or unconditional diffusion with the gradient from the externally trained classifier. To ensure the high quality of generated samples, the original method was introduced with a classifier trained on noised images. However, such an approach can be impractical and lead to limited performance.

Building upon the work by Bansal et al. [], in our method, we adapt the guidance process to utilize a classifier trained only on clean images. To that end, in the guidance process, we first predict denoised image $\hat{\mathbf{z}}_{0}(\mathbf{x}_{t})$, as in Eq. 4. We can then modify the prediction of diffusion model $\epsilon_{\theta}(\mathbf{x}_{t},t)$ at each time step $t$ according to:

$$ ${\hat{\epsilon}}_{\theta}(\mathbf{x}_{t},t)\,=\,\epsilon_{\theta}(\mathbf{x}_{ t},t)\,+\,s\nabla_{\mathbf{x}_{t}}{\ell}\left(f_{\phi}(y|\hat{\mathbf{z}}_{0}( \mathbf{x}_{t})),y\right),$ (5) $$

where $s$ is gradient scale, $f_{\phi}(y|\mathbf{x})$ is classifier model with parameters $\phi$, $\ell$ is the cross-entropy loss function and $y$ is class label that we guide to.

### 3.3 Continual learning with generative replay

In this work, we focus on class-incremental continual learning [] of a classifier $f_{\phi}(y|\mathbf{x})$ with generative replay, where we use diffusion model $\epsilon_{\theta}(\mathbf{x}_{t},t,y)$ as a generator of synthetic samples from previous tasks. The data stream comprises of $T$ distinct tasks. Each task $i$ has its associated dataset $\mathcal{D}_{i}$ with collection of $N$ pairs $\{(\mathbf{x}_{i}^{j},y_{i}^{j})\}_{j=1}^{N}$, where $\mathbf{x}_{i}^{j}$ and $y_{i}^{j}$ represent the $j$-th input sample and its corresponding label, respectively.

In each task $i\in[1,\dots,T]$
we train a classifier $f_{\phi_{i}}(y|\mathbf{x})$ that we optimize towards best performance on all preceding and current tasks,
which can be achieved by minimizing the following loss function:

$$ $\mathcal{L}_{i}=\sum_{k=1}^{i}\sum_{j=1}^{N}\ell(f_{\phi_{i}}(\mathbf{x}_{k}^{ j}),y_{k}^{j}),$ (6) $$

where $\ell$ denotes the cross-entropy loss function. However, we do not have direct access to training data from previous tasks in the CL scenario.
Therefore, we train the classifier model on the combination of real data from the current task and generations from previous tasks generated from a diffusion model.
To that end, the loss function in $i$-th task can be formulated as:

$$ $\mathcal{L}_{i}=\sum_{k=1}^{i-1}\sum_{j=1}^{N}\ell(f_{\phi_{i}}(\hat{\mathbf{x }}_{k}^{j}),y_{k}^{j})+\sum_{j=1}^{N}\ell(f_{\phi_{i}}(\mathbf{x}_{i}^{j}),y_{ i}^{j}),$ (7) $$

where as $\hat{\mathbf{x}}_{k}^{j}$ we denote the $j$-th generation from $k$-th task. Each generation is sampled from the diffusion model trained on the previous task $i-1$.

In this work, we evaluate how to generate rehearsal examples from the diffusion model to maximize the overall performance of a continually trained classifier. We do not apply any modifications to the generative replay in DDPM itself.

## 4 Method

This section introduces GUIDE - a novel method designed to mitigate catastrophic forgetting in a classifier trained in a generative replay scenario with a diffusion model. We benefit from the classifier trained on the current task, referred to as the *current classifier*, to guide the diffusion model during the generation of rehearsal examples from preceding tasks. With our method, we can generate rehearsal examples close to the classifier’s decision boundary, making them highly valuable to counteract the classifier’s forgetting in class-incremental learning [, ].

### 4.1 Intuition and rationale behind GUIDE

Before moving to the continual-learning setup, we demonstrate the effect of guiding the diffusion model towards classes not included in its training dataset. To that end, we propose a simplified scenario in which we employ the unconditional diffusion model $\epsilon_{\theta}(\mathbf{x}_{t},t)$ trained exclusively on the goldfish and tiger shark classes from the ImageNet100 dataset, along with a classifier $f_{\phi}(y|\mathbf{x})$ trained on entire ImageNet dataset.

Given the diffusion model’s unconditional nature, we use the classifier to steer the denoising process toward either the goldfish or tiger shark class, represented as $c_{1}$. Simultaneously, we add another guiding signal from the same classifier $f_{\phi}(y|\mathbf{x})$ towards one of the classes from the ImageNet dataset different than goldfish and tiger shark, denoted as $c_{2}$. Formally, we modify the unconditional diffusion sampling process as follows:

$$ ${\hat{\epsilon}}_{\theta}(\mathbf{x}_{t},t)=\epsilon_{\theta}(\mathbf{x}_{t},t )+s_{1}\nabla_{\mathbf{x}_{t}}{\ell}\left(f_{\phi}(y|\hat{\mathbf{z}}_{0}( \mathbf{x}_{t})),c_{1}\right)+s_{2}\nabla_{\mathbf{x}_{t}}{\ell}\left(f_{\phi} (y|\hat{\mathbf{z}}_{0}(\mathbf{x}_{t})),c_{2}\right).$ (8) $$

In Fig. 2, we present generated samples, with goldfish generations in the upper row and tiger sharks in the bottom one.
Additionally, we present more samples generated using this technique in Appendix H.

By integrating guidance to both $c_{1}$ and $c_{2}$ classes, we generate samples from the diffusion model’s training data distribution – all of the examples are either goldfishes or sharks but with visible features from classes $c_{2}$, which are unknown to the diffusion model (e.g., oblong shape of baguette, hay or snow in the background).

In this work, we propose to use this observation in the continual training of a classifier, with the distinction that in GUIDE, we only utilize guidance toward unknown classes since we sample from a class-conditional diffusion model. Thus, we eliminate the need the need for guidance toward classes from the diffusion model’s training set.

Figure: Figure 2: Samples from the unconditional diffusion model trained only on goldfish and tiger shark classes from the ImageNet100 dataset. In the upper row, we present the samples guided to the goldfish class, while in the bottom row, to the tiger shark class. At the same time, the classifier guides the denoising process toward the class depicted above each figure that was not included in the training set of the diffusion model. For reference, in the leftmost column, we present samples generated without guidance toward any unknown class, setting $s_{2}=0$. In every other column, we set both $s_{1}$ and $s_{2}$ to $10$. We obtain samples from the desired class with observable features of classes unknown to the diffusion model, such as the color, background, or shape.
Refer to caption: x1.png

### 4.2 Guidance toward classes from current task

Our method builds upon the standard generative replay approach with a diffusion model. In each task $i$, we begin by training a classifier $f_{\phi_{i}}(y|\mathbf{x})$ on a combination of real data samples $\mathcal{D}_{i}$ and samples generated from the frozen previous diffusion model $\epsilon_{\theta_{i-1}}(\mathbf{x}_{t},t,y)$. Subsequently, we train a class-conditional diffusion model $\epsilon_{\theta_{i}}(\mathbf{x}_{t},t,y)$ on currently available data $\mathcal{D}_{i}$ along with synthetic data samples from preceding tasks generated by the previous diffusion model $\epsilon_{\theta_{i-1}}(\mathbf{x}_{t},t,y)$.

When generating each rehearsal sample for classifier training, we guide the diffusion sampling process to one of the classes from the current task $i$.

Assuming that we want to generate a replayed sample from class $y_{i-1}$, we modify the diffusion denoising process at each time step $t$ according to the Eq. 5, as follows:

$$ ${\hat{\epsilon}}_{\theta_{i-1}}(\mathbf{x}_{t},t,y_{i-1})=\epsilon_{\theta_{i- 1}}(\mathbf{x}_{t},t,y_{i-1})+s\nabla_{\mathbf{x}_{t}}{\ell}\left(f_{\phi_{i}} (y|\hat{\mathbf{z}}_{0}(\mathbf{x}_{t}),y_{i}\right).$ (9) $$

Since task $i$ can contain many classes, in each denoising step $t$, we select class $y_{i}$ from a current task that at that moment yields the highest output from the classifier:

$$ $y_{i}=\underset{c\in\mathcal{C}_{i}}{\mathrm{argmax}}f_{\phi_{i}}(y=c|\hat{ \mathbf{z}}_{0}(\mathbf{x}_{t})),$ (10) $$

where $\mathcal{C}_{i}$ denotes the set of classes in current task $i$.

Intuitively, this modification steers the diffusion process towards examples from the current task, as depicted in Fig. 1.
Simultaneously, since we utilize only the previous frozen diffusion model that is not trained on classes from the current task, we consistently obtain samples from desired class $y_{i-1}$.
Rehearsal examples obtained with the modified sampling process yield lower outputs for class $y_{i-1}$ in the current classifier $f_{\phi_{i}}(y|\mathbf{x})$ compared to the previous classifier $f_{\phi_{i-1}}(y|\mathbf{x})$. Hence, these examples can be interpreted as data samples that are more likely to be forgotten during continual training. We experimentally validate this statement in Sec. 5.4.
The effect of our guidance technique resembles the idea introduced in Retrospective Adversarial Replay (RAR) [], where authors show that training the classifier on rehearsal samples similar to examples from the current task helps the model to learn the boundaries between tasks. This is also in line with observation by Toneva et al. [], who show that the sample’s distance from the decision border is correlated with the number of forgetting events.

## 5 Experiments

### 5.1 Experimental setup

#### Datasets

We evaluate our approach on CIFAR-10 and CIFAR-100 [] image datasets.
We split the CIFAR-10 dataset into 2 and 5 equal tasks and the CIFAR-100 dataset into 5 and 10 equal tasks. Moreover, to validate if our method can be extended to datasets with higher resolution, we also evaluate it on the ImageNet-100 [] dataset split into 5 tasks.

#### Metrics

For evaluation on each task $i\in[1,\dots,T]$, we use two metrics commonly used in continual learning: average accuracy $\bar{A}_{i}=\frac{1}{i}\sum_{j=1}^{i}A_{j}^{i}$ and average forgetting $\bar{F}_{i}=\frac{1}{i-1}\sum_{j=1}^{i-1}\max_{1\leq k\leq i}(A_{j}^{k}-A_{j}^
{i})$, where $A_{j}^{i}$ denotes the accuracy of a model on $j$-th task after training on $i$ tasks. We follow the definitions of both metrics from [].

**Table 1: Comparison of GUIDE with other generative rehearsal methods (we mark feature replay methods in gray color). Our approach outperforms most other methods in terms of both average accuracy and average forgetting after the final task $T$.**
|  | Average accuracy $\bar{A}_{T}$ ($\uparrow$) | Average forgetting $\bar{F}_{T}$ ($\downarrow$) |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method | CIFAR-10 | CIFAR-100 | ImageNet100 | CIFAR-10 | CIFAR-100 | ImageNet100 |  |  |  |  |
| $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ | $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ |  |
| Joint | 93.14 $\pm$ 0.16 | 72.32 $\pm$ 0.24 | 66.85 $\pm$ 2.25 | - | - | - | - | - |  |  |
| Continual Joint | 85.63 $\pm$ 0.39 | 86.41 $\pm$ 0.32 | 73.07 $\pm$ 0.01 | 64.15 $\pm$ 0.98 | 50.59 $\pm$ 0.35 | 07.91 $\pm$ 0.67 | 02.90 $\pm$ 0.08 | 07.80 $\pm$ 0.55 | 06.67 $\pm$ 0.36 | 12.28 $\pm$ 0.07 |
| Fine-tuning | 47.22 $\pm$ 0.06 | 18.95 $\pm$ 0.20 | 16.92 $\pm$ 0.03 | 9.12 $\pm$ 0.04 | 13.49 $\pm$ 0.18 | 92.69 $\pm$ 0.06 | 94.65 $\pm$ 0.17 | 80.75 $\pm$ 0.22 | 87.67 $\pm$ 0.07 | 64.93 $\pm$ 0.00 |
| DGR VAE | 60.24 $\pm$ 1.53 | 28.23 $\pm$ 3.84 | 19.66 $\pm$ 0.27 | 10.04 $\pm$ 0.17 | 9.54 $\pm$ 0.26 | 43.91 $\pm$ 5.40 | 57.21 $\pm$ 9.82 | 42.10 $\pm$ 1.40 | 60.31 $\pm$ 4.80 | 40.26 $\pm$ 0.91 |
| DGR+distill | 52.40 $\pm$ 2.58 | 27.83 $\pm$ 1.20 | 21.38 $\pm$ 0.61 | 13.94 $\pm$ 0.13 | 11.77 $\pm$ 0.47 | 70.84 $\pm$ 6.35 | 43.43 $\pm$ 2.60 | 29.30 $\pm$ 0.40 | 21.15 $\pm$ 1.30 | 41.17 $\pm$ 0.43 |
| RTF | 51.80 $\pm$ 2.56 | 30.36 $\pm$ 1.40 | 17.45 $\pm$ 0.28 | 12.80 $\pm$ 0.78 | 8.03 $\pm$ 0.05 | 60.49 $\pm$ 5.54 | 51.77 $\pm$ 1.00 | 47.68 $\pm$ 0.80 | 45.21 $\pm$ 5.80 | 41.2 $\pm$ 0.20 |
| MeRGAN | 50.54 $\pm$ 0.08 | 51.65 $\pm$ 0.40 | 09.65 $\pm$ 0.14 | 12.34 $\pm$ 0.15 | - | - | - | - | - | - |
| BIR | 53.97 $\pm$ 0.97 | 36.41 $\pm$ 0.82 | 21.75 $\pm$ 0.08 | 15.26 $\pm$ 0.49 | 8.63 $\pm$ 0.19 | 64.97 $\pm$ 2.15 | 65.28 $\pm$ 1.27 | 48.38 $\pm$ 0.44 | 53.08 $\pm$ 0.75 | 40.99 $\pm$ 0.36 |
| GFR | 64.13 $\pm$ 0.88 | 26.70 $\pm$ 1.90 | 34.80 $\pm$ 0.26 | 21.90 $\pm$ 0.14 | 32.95 $\pm$ 0.35 | 25.37 $\pm$ 6.62 | 49.29 $\pm$ 6.03 | 19.16 $\pm$ 0.55 | 17.44 $\pm$ 2.20 | 20.37 $\pm$ 1.47 |
| DDGR | 80.03 $\pm$ 0.65 | 43.69 $\pm$ 2.60 | 28.11 $\pm$ 2.58 | 15.99 $\pm$ 1.08 | 25.59 $\pm$ 2.29 | 22.45 $\pm$ 1.13 | 62.51 $\pm$ 3.84 | 60.62 $\pm$ 2.13 | 74.70 $\pm$ 1.79 | 49.52 $\pm$ 2.52 |
| DGR diffusion | 77.43 $\pm$ 0.60 | 59.00 $\pm$ 0.57 | 28.25 $\pm$ 0.22 | 15.90 $\pm$ 1.01 | 23.92 $\pm$ 0.92 | 26.32 $\pm$ 0.90 | 40.38 $\pm$ 0.32 | 68.70 $\pm$ 0.65 | 80.38 $\pm$ 1.34 | 54.44 $\pm$ 0.14 |
| GUIDE | 81.29 $\pm$ 0.75 | 64.47 $\pm$ 0.45 | 41.66 $\pm$ 0.40 | 26.13 $\pm$ 0.29 | 39.07 $\pm$ 1.37 | 14.79 $\pm$ 0.36 | 24.84 $\pm$ 0.05 | 44.30 $\pm$ 1.10 | 60.54 $\pm$ 0.82 | 27.60 $\pm$ 3.28 |

#### Baseline methods

We compare our approach with state-of-the-art generative replay methods.
For fairness, in the evaluation of BIR [], we freeze the encoder model after training on the first task. In order to evaluate MeRGAN [] on generative replay scenario, we generate samples from the final generator network trained sequentially on all tasks to construct a training dataset for the ResNet18 classifier.
We also compare the results to the Joint training on all data and simple Fine-tuning with no rehearsal.
As a soft upper bound of the proposed method, we present a Continual Joint setting, where we train the classifier continually with full access to all previous tasks (perfect rehearsal with infinite buffer size).
In all methods using the diffusion model (including DDGR), we use the same number of denoising steps to obtain rehearsal samples. We recalculated scores for all related methods using the code provided by the authors. Importantly, we do not use any pre-training on external datasets.

### 5.2 Implementation details

Our training procedure is divided into two parts. First, in each task $i$, we train the classifier $f_{\phi_{i}}(y|\mathbf{x})$. In order to generate rehearsal samples, we load the diffusion model $\epsilon_{\theta_{i-1}}(\mathbf{x}_{t},t,y)$ already trained on the previous task. Then, we train a class-conditional diffusion model $\epsilon_{\theta_{i}}(\mathbf{x}_{t},t,y)$ in a standard self-rehearsal approach, independently of the classifier. In the first task, we train both the diffusion model and the classifier solely on real data samples.

In our method, it is essential to generate rehearsal examples progressively as the classifier is trained on the task. This way, similarly to active learning techniques, at each step, we guide the generation process toward the most challenging samples – those that are close to the decision boundary of the classifier at the given moment. The mini-batches are balanced to ensure that each contains an equal number of samples from each class encountered so far.
For clarity, we present a detailed pseudocode of the entire training procedure in Appendix C.
All training hyperparameters can be found in Appendix D and in the code repository(^1^11[https://github.com/cywinski/guide](https://github.com/cywinski/guide)).

### 5.3 Experimental results

Figure: Figure 3: Accuracy on each task during each phase of class-incremental training on CIFAR-100 with 5 tasks - standard GR with diffusion (left), GFR (middle), and our method (right). We observe the stability-plasticity trade-off, where our method significantly reduces forgetting compared to the standard GR scenario at the cost of a slight decrease in the ability to learn new tasks.
Refer to caption: x2.png

We evaluate our method on a set of CL benchmarks with a comparative analysis conducted in relation to other generative rehearsal techniques. In Tab. 1, we present the mean and standard deviation of results calculated for 3 random seeds. Our method outperforms other evaluated methods regarding the average accuracy after the last task $\bar{A}_{T}$ by a considerable margin on all benchmarks. Specifically, GUIDE notably improves upon the standard DGR with diffusion model on both average incremental accuracy and forgetting. It also outperforms DDGR, another GR approach that uses the diffusion model, proving the superiority of our sampling technique.

We further compare our method to feature replay methods (BIR and GFR). In the case of the GFR, we observe less forgetting on the CIFAR-100 and ImageNet100 datasets. This is the effect of the drastically limited plasticity of GFR due to the decrease in the number of updates to the feature extractor after the first task. For a more detailed analysis, in Fig. 3
we thoroughly benchmark our method against the standard GR scenario and GFR method, presenting the accuracy on each encountered task after each training phase on CIFAR-100 with 5 tasks. Our approach significantly improved upon the standard GR scenario in terms of knowledge retention from preceding tasks.
It indicates that training on rehearsal examples generated by GUIDE successfully mitigates forgetting.
The decreased accuracy on the most recent task in our method can be interpreted through the lens of the stability-plasticity trade-off [], highlighting that while our approach substantially reduces the forgetting of classifier, it does so at the expense of its ability to assimilate new information. Although GFR can maintain the performance on the initial task notably better than our method thanks to limited training of feature extractor on subsequent tasks, it leads to a substantial final performance drop.

### 5.4 Analysis of the proposed guidance

**Table 2: Proportion of misclassified rehearsal samples after the perturbation. Samples generated via GUIDE exhibit a higher misclassification rate, signifying their proximity to the classifier’s decision boundary. Moreover, rehearsal samples in our method yield lower outputs for both previous and current classifiers.**
|  | misclassified | confidence |  |
| --- | --- | --- | --- |
|  | examples | prev | curr |
| DGR diffusion | 55.13% | 99.6% | 90.03% |
| GUIDE | 72.66% | 86.42% | 61.61% |

To demonstrate that our method produces samples near the decision boundary of a classifier, we propose to launch a simple adversarial attack on the generated samples in order to check how easy it is to change their class to the one from the current task.
Concretely, we adapt the method introduced by Goodfellow et al. [], and modify each rehearsal sample that was generated during training $\hat{\mathbf{x}}$ as follows:

$$ $\hat{\mathbf{x}}^{*}=\hat{\mathbf{x}}-\epsilon\text{sign}\left(\nabla_{\hat{ \mathbf{x}}}\ell(f_{\phi_{i}}(y|\hat{\mathbf{x}}),y_{i})\right),$ (11) $$

where $\epsilon=0.1$ and $y_{i}=\underset{c\in\mathcal{C}_{i}}{\mathrm{argmax}}\;f_{\phi_{i}}(y=c|\hat{
\mathbf{x}})$.

Then, we calculate the proportion of cases where the classifier’s prediction for the modified sample $\hat{\mathbf{x}}^{*}$ differs from its prediction for the original generated sample $\hat{\mathbf{x}}$. As shown in Tab. 2, we can change the classifier’s prediction much more frequently when we sample the replay examples according to our method. Since rehearsal examples generated with GUIDE are much more likely to be misclassified after a simple modification with predefined magnitude, this indicates that the modification of diffusion’s prediction introduced in our method successfully moves the generations closer to the classifier’s decision boundary.

Moreover, we present a visualization of generated samples in the latent space of a classifier (Fig. 4) that we calculate during the training of the second task on a CIFAR-10 dataset divided into five equal tasks. In the standard GR scenario, the rehearsal samples originate predominantly from high-density regions of class manifolds, which is evident from their central location within each class’s manifold. On the other hand, our method yields generations that are more similar to the examples from the second task.

## 6 Additional analysis

### 6.1 The effect of changing classifier scale

Figure: Figure 4: Visualization of the classifiers embedding space (umap) for training examples and generations sampled with standard generative replay method (left) and ours (right) at 75% of the training on the second task. We can observe how GUIDE sample generations are more similar to the training examples from new classes (e.g., airplanes similar to birds).
Refer to caption: x3.png

An important hyperparameter of our method is the gradient scaling parameter $s$ that controls the strength of the guidance signal. In this section, we show the effect of the gradient scale $s$ on the effectiveness of our method. However, our method is robust and can work well with different values of this parameter. The detailed results with other scaling parameters are presented in Appendix A.
As we increase the scale, we observe the inflection point, after which the accuracy starts to drop. This is related to the observation that with excessively large scaling parameters,
the quality of generated samples drops significantly.

In Fig. 5, we present results averaged over 3 random seeds for different values of gradient scale $s$, presenting standard deviation as error bars. We observe that the scaling parameter introduces a trade-off between the stability and plasticity of the continually trained classifier. When we increase $s$, the accuracy on the previous task increases along with a drop in accuracy on the current task.

### 6.2 Alternative variants of guidance

In addition to our primary method, we evaluate alternative variants of incorporating classifier guidance to generative replay setup, drawing inspiration from corresponding techniques in buffer-based rehearsal. Each variant effectively modifies the sampling strategy from the diffusion model. In each variant, we benefit either from the frozen classifier $f_{\phi_{i-1}}(y|\mathbf{x})$, trained on prior tasks and henceforth referred to as the *previous classifier*, or the currently trained classifier, $f_{\phi_{i}}(y|\mathbf{x})$. In this section, we define each variant highlighting with the blue color the distinctions from GUIDE.

**Table 3: Comparison of evaluated variants of integrating classifier guidance in CL. PREV and CURR refers to guidance from previous and current classifier respectively. Guidance toward classes from the previous tasks is denoted with "-" and guidance towards classes from the current task with "+". Each of the introduced variants outperforms standard DGR with diffusion model on most of the evaluated benchmarks and achieves state-of-the-art performance.**
|  | Average accuracy $\bar{A}_{T}$ ($\uparrow$) | Average forgetting $\bar{F}_{T}$ ($\downarrow$) |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Variant | CIFAR-10 | CIFAR-100 | ImageNet100 | CIFAR-10 | CIFAR-100 | ImageNet100 |  |  |  |  |
| $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ | $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ |  |
| DGR diffusion | 77.43 $\pm$ 0.60 | 59.00 $\pm$ 0.57 | 28.25 $\pm$ 0.22 | 15.90 $\pm$ 1.01 | 23.92 $\pm$ 0.92 | 26.32 $\pm$ 0.90 | 40.38 $\pm$ 0.32 | 68.70 $\pm$ 0.65 | 80.38 $\pm$ 1.34 | 54.44 $\pm$ 0.14 |
| PREV + | 80.03 $\pm$ 0.65 | 60.31 $\pm$ 0.44 | 31.35 $\pm$ 0.66 | 18.22 $\pm$ 0.52 | 29.13 $\pm$ 2.81 | 22.45 $\pm$ 1.13 | 40.00 $\pm$ 0.60 | 64.80 $\pm$ 1.00 | 77.60 $\pm$ 0.50 | 45.15 $\pm$ 3.64 |
| PREV - | 75.79 $\pm$ 1.20 | 57.05 $\pm$ 0.43 | 28.40 $\pm$ 0.04 | 15.79 $\pm$ 0.21 | 12.60 $\pm$ 0.71 | 27.58 $\pm$ 0.95 | 44.80 $\pm$ 0.90 | 68.34 $\pm$ 0.29 | 80.42 $\pm$ 0.44 | 59.98 $\pm$ 0.28 |
| CURR - | 78.72 $\pm$ 0.58 | 57.72 $\pm$ 0.95 | 30.57 $\pm$ 0.33 | 16.87 $\pm$ 0.83 | 23.55 $\pm$ 3.27 | 23.89 $\pm$ 0.44 | 43.31 $\pm$ 1.50 | 65.42 $\pm$ 0.81 | 78.96 $\pm$ 1.16 | 53.85 $\pm$ 3.60 |
| GUIDE | 81.29 $\pm$ 0.75 | 64.47 $\pm$ 0.45 | 41.66 $\pm$ 0.40 | 26.13 $\pm$ 0.29 | 39.07 $\pm$ 1.37 | 14.79 $\pm$ 0.36 | 24.84 $\pm$ 0.05 | 44.30 $\pm$ 1.10 | 60.54 $\pm$ 0.82 | 27.60 $\pm$ 3.28 |

#### Guidance towards classes from previous tasks

The most straightforward adaptation of a classifier guidance concept to a generative replay setup is to modify the diffusion sampling process using the gradients from the previous frozen classifier to refine the quality of rehearsal samples. The modification of the previous diffusion model’s prediction can be thus defined as:

$$ ${\hat{\epsilon}}_{\theta_{i-1}}(\mathbf{x}_{t},t,y_{i-1})=\epsilon_{\theta_{i- 1}}(\mathbf{x}_{t},t,y_{i-1})+s\nabla_{\mathbf{x}_{t}}{\ell}\left({\color[rgb] {0,0,1}f_{\phi_{i-1}}}(y|\hat{\mathbf{z}}_{0}(\mathbf{x}_{t})),{\color[rgb]{ 0,0,1}y_{i-1}}\right),$ (12) $$

where $y_{i-1}$ denotes the class label from one of the previous tasks. As noted by [], the application of classifier guidance creates a trade-off: it enhances the quality of the generated samples at the cost of their diversity. This approach is similar to the one introduced by Gao and Liu [] except that we do not use guidance in the process of continual diffusion training but only in the classifier’s training. Intuitively similar buffer-based methods are based on the herding algorithm [] and used in iCaRL method [], which seeks to store samples that best represent the mean of classes in the feature space.

#### Guidance away from classes from previous tasks

Alternatively, we can guide the diffusion-denoising process in the opposite direction by
maximizing the entropy of the classifier instead of minimizing it. As noted by Sehwag et al. [], such an approach steers the denoising diffusion process away from the high-density regions of the data manifold. Consequently, it should generate synthetic samples that resemble the rare instances in the training dataset, which are typically more challenging for the classifier to identify.
In the first variant, we propose to use the previous classifier $f_{\phi_{i-1}}(y|\mathbf{x})$ to guide away from the old classes:

$$ ${\hat{\epsilon}}_{\theta_{i-1}}(\mathbf{x}_{t},t,y_{i-1})=\epsilon_{\theta_{i- 1}}(\mathbf{x}_{t},t,y_{i-1}){\color[rgb]{0,0,1}-}s\nabla_{\mathbf{x}_{t}}{ \ell}\left({\color[rgb]{0,0,1}f_{\phi_{i-1}}}(y|\hat{\mathbf{z}}_{0}(\mathbf{x }_{t})),{\color[rgb]{0,0,1}y_{i-1}}\right).$ (13) $$

Analogously, we can steer the diffusion denoising process away from the desired class from the previous task, but using the current classifier $f_{\phi_{i}}(y|\mathbf{x})$:

$$ ${\hat{\epsilon}}_{\theta_{i-1}}(\mathbf{x}_{t},t,y_{i-1})=\epsilon_{\theta_{i- 1}}(\mathbf{x}_{t},t,y_{i-1}){\color[rgb]{0,0,1}-}s\nabla_{\mathbf{x}_{t}}{ \ell}\left(f_{\phi_{i}}(y|\hat{\mathbf{z}}_{0}(\mathbf{x}_{t})),{\color[rgb]{ 0,0,1}y_{i-1}}\right).$ (14) $$

Figure: Figure 5: Classifier scale impact on forgetting and ability to acquire new information. Up to $s=0.2$, when we increase scale, we reduce the forgetting but also observe a drop in the accuracy on the second task. When we use too large scale $s$, the quality of samples drops significantly, along with the accuracy on the previous task. We further present this effect in Appendix A.
Refer to caption: x4.png

In both approaches, we increase the diversity
of rehearsal samples under frozen or continually trained classifiers. This variation resembles the buffer-based method of Gradient Sample Selection (GSS) [], which seeks to maximize the diversity of the samples stored in the memory buffer.

#### Evaluation

We evaluate the performance of each proposed variant and present the mean and standard deviation of those experiments on CL benchmarks in Tab. 3, which are calculated for 3 random seeds. We can observe that thanks to the improved quality of rehearsal samples, approaches integrating guidance towards selected classes achieve higher overall performance.
In simpler scenarios, increasing the diversity of generated samples can also yield slight improvement, while in more complex settings, its performance is comparable to the baseline. Nevertheless, in all evaluated scenarios, our proposed guidance towards forgotten examples outperforms competing approaches.

## 7 Discussion and limitations

In this work, we focus on the continual learning of a classifier given a continually trained diffusion model. In our experiments, we train the diffusion model with simple generative replay – a potentially suboptimal solution. As presented in Appendix B, the significant drawback of our method is the forgetting happening in the diffusion model itself. Our initial results suggest that because of the known issue of sample deficiency from low-density regions [] forgetting in diffusion models manifests itself as a degradation of the diversity of generated samples, which has an important effect on the quality of rehearsal samples. We discuss this issue briefly in Appendix E. Nevertheless, the forgetting of diffusion models is an open research question.
An important drawback of all generative replay approaches is the computational burden associated with training and sampling from the diffusion model. This is also true for our method, which is computationally expensive. However, GUIDE is only slightly more computationally expensive than standard DGR with diffusion and significantly less expensive than a recent state-of-the-art solution – DDGR, while yielding better results. Moreover, we evaluate additional speed-up techniques that mitigate this burden. Detailed analysis is provided in Appendix G.

## 8 Conclusion

In this work, we propose GUIDE: generative replay method that utilizes classifier guidance to generate rehearsal samples that the classifier model is likely to forget.
We benefit from a classifier trained continually in each task to guide the denoising diffusion process toward the most recently encountered classes. This strategy enables the classifier’s training with examples near its decision boundary, rendering them particularly valuable for continual learning.
Across various CL benchmarks, GUIDE demonstrates superior performance, consistently surpassing recent state-of-the-art generative rehearsal methods. This underscores the effectiveness of our approach in mitigating forgetting and training a robust classifier.

## Appendix A Impact of classifier scale hyperparameter on our method

To measure the effect of changing the strength of guidance scale parameter $s$ on the effectiveness of our method, we sweep over each value in $[0.1,0.2,0.5,1.0]$ for each evaluated benchmark. We present the mean and standard deviation of results in Tab. 4 calculated for 3 different values of random seed. We see that with this hyperparameter properly tuned, we are able to improve the results of our method further. Nonetheless, the results we achieved show that our method works well with different values of this hyperparameter.

**Table 4: Effect of gradient scale $s$ on GUIDE. By tuning this hyperparameter, we can improve the results further.**
|  | Average accuracy $\bar{A}_{T}$ ($\uparrow$) | Average forgetting $\bar{F}_{T}$ ($\downarrow$) |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Scale $s$ | CIFAR-10 | CIFAR-100 | ImageNet100-64 | CIFAR-10 | CIFAR-100 | ImageNet100-64 |  |  |  |  |
| $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ | $T=2$ | $T=5$ | $T=5$ | $T=10$ | $T=5$ |  |
| 0.0 | 77.43 $\pm$ 0.60 | 56.61 $\pm$ 1.85 | 28.25 $\pm$ 0.22 | 15.90 $\pm$ 1.00 | 23.92 $\pm$ 0.92 | 26.32 $\pm$ 0.90 | 43.79 $\pm$ 0.41 | 68.70 $\pm$ 0.65 | 80.38 $\pm$ 1.34 | 54.44 $\pm$ 0.14 |
| 0.1 | 80.66 $\pm$ 0.44 | 59.56 $\pm$ 0.52 | 31.63 $\pm$ 0.81 | 18.28 $\pm$ 0.93 | 26.48 $\pm$ 3.79 | 18.81 $\pm$ 0.48 | 39.78 $\pm$ 0.92 | 63.87 $\pm$ 1.35 | 78.01 $\pm$ 0.59 | 50.09 $\pm$ 5.04 |
| 0.2 | 81.29 $\pm$ 0.75 | 61.30 $\pm$ 0.10 | 37.51 $\pm$ 1.23 | 22.68 $\pm$ 0.30 | 31.09 $\pm$ 4.17 | 14.79 $\pm$ 0.36 | 34.98 $\pm$ 0.13 | 54.52 $\pm$ 1.45 | 70.68 $\pm$ 0.23 | 44.40 $\pm$ 5.02 |
| 0.5 | 78.30 $\pm$ 0.47 | 64.47 $\pm$ 0.45 | 41.66 $\pm$ 0.40 | 25.48 $\pm$ 1.16 | 35.82 $\pm$ 0.56 | 20.03 $\pm$ 1.85 | 29.25 $\pm$ 1.15 | 44.30 $\pm$ 1.10 | 64.06 $\pm$ 1.53 | 35.80 $\pm$ 0.32 |
| 1.0 | 73.46 $\pm$ 0.81 | 62.56 $\pm$ 0.52 | 39.55 $\pm$ 0.19 | 26.13 $\pm$ 0.29 | 39.07 $\pm$ 1.37 | 30.96 $\pm$ 1.93 | 24.05 $\pm$ 0.72 | 44.03 $\pm$ 0.34 | 60.54 $\pm$ 0.82 | 27.60 $\pm$ 3.29 |

Moreover, in Fig. 6, we present random rehearsal samples from our CIFAR-10 setup with 2 tasks generated from the same initial noise in each column. We observe the effect of classifier scale parameter $s$ on the quality of rehearsal samples in GUIDE. If we set the scale to be too large, we observe significant degradation in the quality of generations. Hence, in Tab. 4, we observe a drop in performance on setups where the scale is too large.

Figure: Figure 6: Sample rehearsal examples of GUIDE generated by class-conditional diffusion model trained on the first task of CIFAR-10/2 setup. If we set the gradient scale parameter $s$ too large, we observe a significant drop in the quality of samples.
Refer to caption: x5.png

## Appendix B Continual learning with ground-truth diffusion

In all of our setups presented in the main part of the article, we trained the diffusion model alongside the continually trained classifier. In this experiment, we study the effect of the rehearsal sampling method proposed in GUIDE under the assumption of a ground-truth sampling method from the previous tasks. We independently train four diffusion models on all of the data presented up to the $i^{th}$ task in the CIFAR100/5 tasks scenario. With those models, we compare our method with the baseline sampling method and continual upper-bound where the classifier has full access to all training data samples from current and previous tasks. We depict the results of this comparison in Fig. 7, calculated for 3 random seeds. We report mean and standard deviation as error bars. Results indicate that the random sampling of rehearsal samples, even from the ground-truth diffusion model, leads to a significant drop in performance. At the same time, our method significantly reduces the difference with the soft-upper bound defined by the continual-joint training with infinite buffer size. Interestingly, our fully continual learning setup still outperforms the baseline sampling approach rehearsed with a ground-truth diffusion.

Figure: Figure 7: Average accuracy on all classes seen so far after $i^{th}$ task. We highlight with asterisks $(\ast)$ methods trained with ground-truth diffusion model. We can observe that under ground-truth diffusion model GUIDE approaches the soft upper-bound defined by the continual joint training.
Refer to caption: x6.png

## Appendix C Pseudocode of training procedure in GUIDE

To clarify and enhance understanding of our continual training process, this section includes pseudocode for the primary components involved in our method. Alg. 1 presents a sampling of a single rehearsal example during the continual training of a classifier in GUIDE. In Alg. 2, we present a complete end-to-end continual training of both diffusion model and classifier in GUIDE.

Since the decision boundary changes during the training of a classifier, we sample new rehearsal examples according to our sampling method progressively once every $N_{g}$ batches. It ensures that replayed examples are located close to the decision boundary of a classifier at the given moment. Simultaneously, hyperparameter $N_{g}$ allows us to significantly speed up our method without a noticeable drop in accuracy, which we describe further in Appendix G. Since we do not use classifier guidance during the generation of a dataset for diffusion training, we sample rehearsal examples all at once and merge them with real data samples.

In the pseudocode, consistent with the terminology used in the main text, the current classifier is denoted as $f_{\phi_{i}}(y|\mathbf{x})$ and the previous diffusion model as $\epsilon_{\theta_{i-1}}(\mathbf{x}_{t},t,y)$. All hyperparameters, such as the number of training steps or the number of denoising steps, are listed in Appendix D.

Figure: Algorithm 1 Rehearsal sampling in GUIDE during training on task $i$

Figure: Algorithm 2 Continual training in GUIDE

## Appendix D Training details and hyperparameters

### D.1 Diffusion models

In our experiments, we follow the definitions of class-conditional diffusion model architectures described in []. Across all setups, we train diffusion models using AdamW optimizer with $\beta_{1}=0.9$ and $\beta_{2}=0.999$. The only hyperparameter that varies between tasks is the number of iterations of training. In all setups, we train models for 100K iterations on the initial task, and then on each subsequent task, we train either for 50K or 100K iterations, depending on the setup. We use DDIM with 250 steps for the generation of rehearsal samples on the ImageNet100 dataset and 1000 denoising steps for every other dataset. The only augmentation that we use during the training of diffusion models is the random horizontal flip.

We present the most important hyperparameters for diffusion models in Tab. 5.

**Table 5: Hyperparameters for the training of diffusion models.**
|  | CIFAR-10/2 | CIFAR-10/5 | CIFAR-100/5 | CIFAR-100/10 | ImageNet100-64/5 |
| --- | --- | --- | --- | --- | --- |
| Diffusion steps | 1000 | 1000 | 1000 | 1000 | 1000 |
| Noise schedule | linear | linear | linear | linear | linear |
| Channels | 128 | 128 | 128 | 128 | 192 |
| Depth | 3 | 3 | 3 | 3 | 3 |
| Channels multiple | 1, 2, 2, 2 | 1, 2, 2, 2 | 1, 2, 2, 2 | 1, 2, 2, 2 | 1, 2, 3, 4 |
| Heads | 4 | 4 | 4 | 4 |  |
| Heads channels |  |  |  |  | 64 |
| Attention resolution | 16,8 | 16,8 | 16,8 | 16,8 | 32,16,8 |
| BigGAN up/downsample | ✗ | ✗ | ✗ | ✗ | ✓ |
| Dropout | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
| Batch size | 256 | 256 | 256 | 256 | 100 |
| Learning rate | 2e-4 | 2e-4 | 2e-4 | 2e-4 | 1e-4 |
| Iterations 1^st task | 100K | 100K | 100K | 100K | 100K |
| Iterations other tasks | - | 50K | 50K | 100K | 50K |
| Self-rehearsal denoising steps | - | 1000 | 1000 | 1000 | DDIM250 |

### D.2 Classifiers

As a classifier model, we use the same ResNet18 architecture as the GDumb method [] in each setup, with preactivation enabled, meaning that we place the norms and activations before the convolutional or linear layers. We train models with an SGD optimizer. We list the most important hyperparameters for classifiers in Tab. 6.

For CIFAR-10 and CIFAR-100 datasets, we define the same set of image augmentations, which include cropping, rotating, flipping, and erasing. We also apply a transformation to the brightness, contrast, saturation, and hue, followed by the normalization to the [-1, 1] range. During the training, we apply the same augmentations for both rehearsal samples and real samples from the current task.

For the ImageNet100, we do not apply any data augmentations, but we also normalize the images to the range of [-1, 1].

**Table 6: Hyperparameters for the training of classifier models.**
|  | CIFAR-10/2 | CIFAR-10/5 | CIFAR-100/5 | CIFAR-100/10 | ImageNet100-64/5 |
| --- | --- | --- | --- | --- | --- |
| Batch size | 256 | 256 | 256 | 256 | 100 |
| Learning rate 1^st task | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 |
| Learning rate other tasks | 0.01 | 0.01 | 0.05 | 0.05 | 0.001 |
| Iterations 1^st task | 5K | 5K | 10K | 10K | 20K |
| Iterations other tasks | 2K | 2K | 2K | 2K | 20K |
| Rehearsal denoising steps | DDIM50 | DDIM50 | DDIM100 | DDIM100 | DDIM50 |
| Rehearsal generation interval | 1 | 5 | 10 | 10 | 15 |

### D.3 Experiments compute resources

In this section, we list the hardware we used for our experiments and training times on each benchmark, both for training of diffusion models in Tab. 7 and classifiers in Tab. 8. Although we use NVIDIA A100 GPUs in our experiments due to the efficiency of training, experiments can also be reproduced on GPUs with smaller memory, as noted in Sec. F.

The total compute used in a project can be estimated from the times presented in tables, considering that each experiment is calculated with three different random seeds for statistical significance. Furthermore, we need to take into account compute used in the development stage of the project.

**Table 7: Training times of diffusion models for each benchmark.**
| Benchmark | Time[GPU-hours] | GPU used |
| --- | --- | --- |
| CIFAR-10/2 | 5.55 | 4 x NVIDIA A100 40GB |
| CIFAR-10/5 | 20 | 4 x NVIDIA A100 40GB |
| CIFAR-100/5 | 20 | 4 x NVIDIA A100 40GB |
| CIFAR-100/10 | 63.75 | 4 x NVIDIA A100 40GB |
| ImageNet100-64/5 | 88.43 | 4 x NVIDIA A100 40GB |

**Table 8: Training times of classifiers for each benchmark.**
| Benchmark | Time[GPU-hours] | GPU used |
| --- | --- | --- |
| CIFAR-10/2 | 4.8 | 1 x NVIDIA A100 40GB |
| CIFAR-10/5 | 5.8 | 1 x NVIDIA A100 40GB |
| CIFAR-100/5 | 5.35 | 1 x NVIDIA A100 40GB |
| CIFAR-100/10 | 13.53 | 1 x NVIDIA A100 40GB |
| ImageNet100-64/5 | 30.73 | 4 x NVIDIA A100 40GB |

## Appendix E Forgetting in diffusion models

### E.1 Coverage of data manifold

In this analysis, we explore the forgetting behavior of a diffusion model trained continually on CIFAR-10, divided into two tasks with 25000 training samples each. Initially, we train the model exclusively on data from the first task (Real Task 1). Subsequently, we employ two approaches: standard self-rehearsal training for the second task (Continual Task 2), akin to our method, and retraining the first task’s model on the entire CIFAR-10 dataset (Upper-bound Task 2), which serves as our upper bound. All training conditions, including architectures, training steps (100K), and hyperparameters, remain consistent across setups. Generative metrics (FID [], Precision, and Recall []) for samples generated with DDIM100 from all models are displayed in Tab. 9.

**Table 9: Comparison of FID, Recall, and Precision metrics of all three trained models. We calculate metrics for 25000 samples generated using DDIM100. When we train the diffusion model in a continual manner, we observe a very significant drop in the Recall.**
|  | FID ($\downarrow$) | Recall ($\uparrow$) | Precision ($\uparrow$) |
| --- | --- | --- | --- |
| Real Task 1 | 9 | 55 | 65 |
| Upper-bound Task 2 | 13 | 52 | 64 |
| Continual Task 2 | 26 | 37 | 67 |

Continual training of the diffusion model leads to a noticeable reduction in its capability to cover the training manifold of Task 1, as evidenced by a decrease in the Recall metric. However, the Precision metric does not show a significant drop, indicating that the quality of the generated samples remains largely unaffected. Moreover, we visualize the umap embeddings of both real data examples and generated samples in Fig. 8. In plot (c), it’s evident that the coverage of real data samples (depicted in blue) by the generated samples has noticeably diminished.

Figure: (a) Initial task 1 data manifold.
Refer to caption: extracted/5634821/Figures/t0.png

### E.2 Forgetting of training data samples

Figure: (a) Samples from class apple remembered by the diffusion model after training on the second task.
Refer to caption: extracted/5634821/Figures/remembered_apples.png

In our study, we further analyze what data samples the diffusion model trained continually tends to forget. We conducted an experiment where we sample examples from class apple from our class-conditional diffusion model, trained on the CIFAR-100 dataset divided into 5 tasks, after completing the second task. Utilizing Precision and Recall metrics definitions [], we computed representations using the Inception-v3 model for both real and generated sample sets. This allowed us to identify which segments of the approximated real data manifold were covered or missed by the generated manifold.

Figure 9(a) illustrates examples of remembered data samples, while Figure 9(b) depicts those data samples that were forgotten by the diffusion model due to continual training. Consistent with findings by Toneva et al. [], our diffusion model tends to forget rare samples in the training set, such as those with complex backgrounds, while retaining more common samples characterized by simpler backgrounds and typical shapes. This is also connected to the drop in Recall, where from task to task, the diffusion model loses the ability to generate samples from low-density regions of data manifold [].

## Appendix F Runtime analysis of GUIDE for CIFAR-10/5

We perform an extensive runtime analysis in order to compare the training times of GUIDE to other existing baselines. For the training of each method, we used the same machine with a single NVIDIA RTX A5000 GPU. Since in the training of GUIDE on CIFAR-10/5 setup, we generate new rehearsal examples every 10 batches, for fairness, we evaluate the DDGR runtime with exactly the same interval. We present the calculated runtimes in Tab. 10.

**Table 10: Runtime analysis of all baseline methods on the CIFAR-10/5 benchmark. (*) We evaluate the DDGR method with the same rehearsal generation interval as we use in GUIDE on this benchmark – once every 10 batches.**
| Method | Time [GPU-hours] |
| --- | --- |
| DGR VAE | 1.28 |
| DGR+distill | 1.35 |
| RTF | 1.09 |
| BIR | 2.49 |
| GFR | 1.76 |
| DDGR | $\text{111.96}^{*}$ |
| DGR diffusion | 76.1 |
| GUIDE | 82.95 |

Approaches that train diffusion models (DDGR, DGR diffusion, and GUIDE) require significantly more computations. However, GUIDE does not increase much of the runtime compared to the standard DGR with diffusion model ($+9\%$ wall time). At the same time, when comparing GUIDE to the recently proposed DDGR [] method that also uses diffusion models in generative replay scenario, our approach needs notably less computation time ($-26\%$ wall time) while achieving better performance in all evaluated setups.

## Appendix G Speed vs accuracy trade-off in GUIDE

We investigate the trade-off between speed and performance of our method. To that end, we study the effect of the number of denoising steps used for rehearsal sampling and the replay’s set size on the performance of GUIDE. In both experiments, we present average accuracy after the final task, along with a speed-up in time.

To investigate the effect of the number of denoising steps used for rehearsal sampling, we test the performance of GUIDE for $[10,20,50,100,250,1000]$ steps of DDIM (Tab. 11). Although the performance tends to increase with a number of denoising steps, the difference in average accuracy is not very significant.

To effectively reduce the size of the replay set, we generate new rehearsal samples once every $[1,5,10,50,100]$ batches of the training (Tab. 12). For completeness, we also present the results for fine-tuning setup - training without any generative replay that can be seen as an upper bound in terms of computational complexity. We observe that increasing the generation interval can not only significantly decrease the training time but also increase the final performance.

Although the sampling process of diffusion models is indeed relatively slow compared to other generative architectures, we show that we can significantly reduce the training time of GUIDE without a notable drop in performance by using either one of the proposed techniques.

**Table 11: Trade-off between the number of denoising steps used for the rehearsal sampling on the effectiveness of GUIDE on CIFAR-10/5 benchmark (default setup from the main text is grayed out).**
| DDIM steps | $\bar{A}_{T}$ | Time [speedup] |
| --- | --- | --- |
| 10 | $59.7\pm 1.04$ | $\times$ 7.3 |
| 20 | $63.7\pm 0.99$ | $\times$ 2.3 |
| 50 | $64.1\pm 0.09$ | $\times$ 1 |
| 100 | $64.2\pm 0.54$ | $\times$ 0.51 |
| 250 | $63.6\pm 0.25$ | $\times$ 0.21 |
| 1000 (no DDIM) | $71.8\pm 0.23$ | $\times$ 0.06 |

**Table 12: Trade-off between the interval of the generation of new rehearsal samples on the effectiveness of GUIDE on CIFAR-10/5 benchmark (default setup from the main text is grayed out).**
| Rehearsal generation interval | $\bar{A}_{T}$ | Time [speed-up] |
| --- | --- | --- |
| 1 | $63.12\pm 0.45$ | $\times$ 0.2 |
| 5 | $64.47\pm 0.45$ | $\times$ 1 |
| 10 | $64.1\pm 0.09$ | $\times$ 1.95 |
| 50 | $59.2\pm 0.47$ | $\times$ 8.49 |
| 100 | $56.9\pm 0.98$ | $\times$ 14.41 |
| $\infty$ (Fine-tuning) | $18.95\pm 0.20$ | $\times$ 49.59 |

## Appendix H Samples from ImageNet100 128x128

[Uncaptioned image]: x7.png

[Uncaptioned image]: x8.png

Figure: Figure 10: Random samples generated from an unconditional diffusion model trained only on goldfish and tiger shark classes from the ImageNet100 128x128 dataset. Each image grid presents samples generated with guidance to the class depicted above the grid which is unknown to the diffusion model. We generate samples using 1000 denoising steps and we set guidance scale $s$ to $10$ for both classes that we guide to.
Refer to caption: x9.png

## Appendix I Samples from CIFAR-10

Figure: Figure 11: Samples from unconditional diffusion model trained only on classes automobile and airplane from the CIFAR-10 dataset. We generate those samples following the same procedure as discussed in Sec. 4.1. On the left grid, we guide the denoising process to automobiles, while on the right grid, to airplanes. At the same time, we add the guidance to classes depicted on the y-axis of the figure. We generate samples using 1000 denoising steps and we set guidance scale $s$ to $5$ for both classes that we guide to.
Refer to caption: x10.png

## Appendix J Broader impacts

This paper presents work whose goal is to advance the field of continual machine learning. There are many potential societal consequences of our work, many of which are generic to the machine learning field in general, i.e., the DGR algorithm considered in this paper will reflect the biases present in the dataset. Hence, it is important to exercise caution when using this technique in applications where dataset biases could lead to unfair outcomes for minority and/or under-represented groups. In our case, this especially concerns training a diffusion model used for replay, in which simple random sampling can result in a different data distribution than the original dataset. It would be worthwhile to actively monitor the model’s outputs for fairness or implement bias correction techniques to mitigate these negative impacts.

Additionally, while diffusion models have shown promise in various generative tasks, their adaptability through fine-tuning and continual learning remains relatively unexplored. In this early-stage research, some potential risks can emerge while combining our proposed algorithm of guidance with malicious models or when performing more sophisticated attacks.

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 3
presentation: 2
questions: None
soundness: 3
strengths: 1) Generating examples in a specific way (i.e., on the decision boundary) to relieve forgetting is novel and compelling
2) leveraging the past classifier as a guidance offers interesting insights
3) the ablation studies outline the impact of different components effectively
summary: The authors propose a deep generative replay methodology for continual learning, which leverages a diffusion model to generate samples that are rehearsed to reduce forgetting. The main idea resides in using *classifier guidance* to guide the generations towards examples that are close to the decision boundary. These samples should be more effective when rehearsed, as they are generated to represent the separation between real examples of different tasks. The methodology proves to be effective on standard continual learning benchmarks.
weaknesses: 1) Experimental results:
 - I did not find the experimental setting clear (e.g., lacking the number of epochs/iterations for each setting)
 - Results reported in Table 1 are suspiciously low (w.r.t. to the results reported by competitors such as DDGR). For instance, DDGR reports an accuracy that is almost **four** times higher on CIFAR-100, 10 tasks.
 - Results in Table 2 are misleading. All methodologies reported as competitors (except for GSS) were introduced for a multi-epoch setup: evaluating them by devising a single epoch may lead to inconsistent and unfair analyses. Certain techniques, such as DER, DER++, DGR Diffusion, and the proposed GUIDE, surpass the continual-joint upper bound in various datasets, highlighting fundamental issues within the current setting (e.g., underfitting of the dataset). Moreover, the same competitor (DER, DER++, iCaRL etc.) yield much higher performance in the original experimental settings, which highlights the need for more training epochs or higher learning rate.
2) Clarity: the explanation of the methodology can generally be improved:
 - A specific aspect is found in line 203, page 4. Here, M_k and D_k are referred to as free parameters, which is inconsistent with their previous definition (D is the dataset at line 196).
 - At first (line 160) the authors introduce an unconditional diffusion model trained exclusively on the goldfish and tiger shark classes from the ImageNet100 dataset. It seems like the diffusion model used for generating the data is always pre-trained, but this is not the case as showed in the algorithms (appendix).
 - Line 168, equation 3. If we wanted to guide the diffusion process away from a class and towards another one, I would expect the two correction factors to have different signs, reflecting opposing directions in gradient space. However, both correction factors currently point in the same direction, which contradicts this expectation.
 - Line 219: what does it mean "a current task"? is there more than one current task? Then, at line 223. The expression "current task i" is misleading: is it the current task or the i^th task?
 - Table 1, 3 and 4 are very small and difficult to read.
 - Line 445: why should maximizing *entropy* of the classifier be of help? Maybe, the authors meant *cross-entropy*?
Additionally, in the caption of Figure 6, the claim of "approaching the continual joint training" is not really met, as there still is a difference of 10+ percentage points.

If find the main idea of this work original and interesting, but I think that its application lacks clarity and experimental significance.

---

confidence: 3
contribution: 3
initial_rating: 5
presentation: 3
questions: Refer to the weakness.
soundness: 3
strengths: The paper provide good intuition of their approach, showcasing it using different qualitative and 2D projection based examples, as to how different techniques sample the space. I also like the hyperparameter sensitivity performed in order to show robustness, and different possible variant of GUIDE. While I've not been in touch with Continual learning community for a while, I think these bare minimum things are necessary.
summary: This paper tackles the task incremental continual learning with the help of generative replay. To do so, they use the diffusion model to generate examples from the previous class, that look similar to the examples of the current class. This is achieved by using classifier guidance. Hypothesis is that examples from the previous tasks that are similar to the current one are most prone to forgetting. Using the method mentioned above, they compare their technique GUIDE against different generative replay based methods, outperforming the baselines. Ablations and sensitivity for the sampling hyperparameters are done to show the robustness of the proposed approach.
weaknesses: In terms of weakness, I've a few questions

- The sampling procedure as outlined in Alg2 in the appendix uses the model $f_{\phi}$ which may or may not be trained well enough in order to be able to understand which class is the image from the previous task  (as generated by the diffusion model during the sampling steps) belong to in the current set of classes in the task. Moreover, shouldn't it affect the classifier guidance as well when sampling from the previous task's class? This conceptually confuses me. 
- I think an ideal situation would have been where one keeps two classifiers, using the one from the immediately previous task form the classifier guidance sampling, and the other (which is being learned for the current task) for providing the gradient of the CE loss. 

On computation, and memory footprint. 

- How large is the final Diffusion model in terms of size? I feel like in practice if the diffusion model costs (space wise) more than storing important (of not all) set of images from the current task, then it defeats the purpose of using the diffusion model. 
- The amount of training time for the diffusion model (as mentioned in the appendix) for even a 100 class dataset like Imagenet 100 seems large to me. 

On loss terms and Baselines 

- What is the overall loss used in this framework? DER++ outperforms GUIDE at certain places, but couldn't one use DER++ loss for this work? 
- Can the authors compare against RAR? (Kumari et al. 2022)

---

confidence: 4
contribution: 1
initial_rating: 5
presentation: 3
questions: 1. In line 96, $y$ in $f _{\phi}\left(y \mid \hat{\mathbf{z}} _{0}\left(\mathbf{x} _{t}\right)\right)$ seems to be useless. Should $f _{\phi}\left(y \mid \hat{\mathbf{z}} _{0}\left(\mathbf{x} _{t}\right)\right)$ be replaced by $f _{\phi}\left(\hat{\mathbf{z}} _{0}\left(\mathbf{x} _{t}\right)\right)$?

2. In line 203, it is stated that "$\mathcal{M} _{k} \subset \mathcal{D} _{k}$ are free parameters". Is $\mathcal{M} _{k}$ not the memory buffer  of samples corresponding to task $k$?

3. $\mathcal{M} _{k} $ is generated according to eq.6 which considers the guided information according to the class of current task $i$ but ignores task $k$. So how does it make sure that the generated samples buffer $\mathcal{M} _{k}$ corresponds to previous task $k$?

4. The contexts from lines 235 to 239 seem to demonstrate that the ways in Section 3.2 is reasonable, but it cannot explain Q3.

5. In line 219, it is stated that "... classes, in each denoising step $t$, ....". Does this mean that the selected class $y _i$ can be different in each step $t$ of the sample generating process? If so, is it reasonable? 

6. What diffusion models are this paper based on, DDPM, DDIM or something else?
soundness: 2
strengths: 1. This paper is well-written and easy to follow.

2. I appreciate the extensive experiments.
summary: This paper focuses on catastrophic forgetting and proposes a generative based continual learning method called GUIDE which incorporates classifier guidance into the diffusion process to produce rehearsal examples specifically targeting information forgotten by a continuously trained model. Experiments are provided to empirically evaluate the proposed method.
weaknesses: My main concern is about the technique contribution of this paper.

1. The main technique of this paper is eq.1 and eq.2,  which comes from [1]. In the view of technique, this paper is not novel. This means that this paper is an (a+b)-like work which merges the technique in [1], diffusion model and continual learning setting. Therefore, i think the lack of technique contribution is the main weakness of this paper.

2.  (a+b)-like work is ok, but this paper doesn't show enough motivations about why the proposed method is a proper solution. The motivation needs to described in details.


[1] Arpit Bansal, Hong-Min Chu, Avi Schwarzschild, Soumyadip Sengupta, Micah Goldblum, Jonas Geiping, and Tom Goldstein. Universal guidance for diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 843–852, 2023.

---

confidence: 5
contribution: 2
initial_rating: 5
presentation: 2
questions: 1. The diffusion sampling (DDIM with 250 steps or so) is relatively costly considering modern standards (e.g., DDIM with 50 or fewer steps or more advanced samplers like unipc with 10-20 steps). How does the performance change if we aim to reduce the sampling costs? Also, if sampling is cheaper, we can sample more hard training data points. How does the performance change then?

2. Is the diffusion model trained progressively for the main result? I.e., first train the model on task 1 and then train on combined task 1 and task 2, and so on. Also, what's the performance of the diffusion model trained on the generated data (I think the main results all use real data for the diffusion model)?
soundness: 3
strengths: 1. The paper introduces the idea of using information from the current task in generating replay samples to generative replay CL.

2. Compared to diffusion-based generative replay CL, the proposed method seems to be a more effective way to utilize the diffusion model.
summary: The paper studies the problem of task incremental continual learning with generative replay. The paper proposes to use diffusion models as the sample generator and guide the diffusion generation process so that the generated samples are most ''confusing'' with the samples of the current task and therefore those samples are most likely to be forgotten. The paper shows that empirically the proposed method outperforms other generative replay CL approaches.
weaknesses: 1. The technical novelty and contribution is limited. The guidance of diffusion model generation follows standard procedures and the high-level idea follows the memory replay CL approach of RAR.

2. The presentation can be improved. Many figures and tables are extremely small (e.g., table 1 and figure 2). Also, eq 6 is confusing. Based on the definition of y_i in eq 7, the y_{i-1} in eq 6 should only refer to a certain class of task i-1, which I don't think is the intention of the author (correct me if I am wrong). A more reasonable definition of y_{i-1} is given much later in the discussion.

3. This is a general weak point for the generative replay CL approach. Compared to memory replay CL, the generative approach requires costly and potentially offline training of the generative model, which makes the approach less practical in real scenarios. The paper does not push forward in the direction of solving this practical issue.