Datasets:
Add files using upload-large-folder tool
Browse files- md/train/14nC8HNd4Ts/14nC8HNd4Ts.md +271 -0
- md/train/3AOj0RCNC2/3AOj0RCNC2.md +417 -0
- md/train/3RMnfrH_Fi8eU/3RMnfrH_Fi8eU.md +134 -0
- md/train/5Dl1378QutR/5Dl1378QutR.md +403 -0
- md/train/5nLibPckV2N/5nLibPckV2N.md +276 -0
- md/train/B1e3OlStPB/B1e3OlStPB.md +531 -0
- md/train/B1lfHhR9tm/B1lfHhR9tm.md +630 -0
- md/train/B1x8anVFPr/B1x8anVFPr.md +617 -0
- md/train/BJxbOlSKPr/BJxbOlSKPr.md +394 -0
- md/train/ByToKu9ll/ByToKu9ll.md +242 -0
- md/train/E3Ys6a1NTGT/E3Ys6a1NTGT.md +0 -0
- md/train/H1Xw62kRZ/H1Xw62kRZ.md +386 -0
- md/train/H1e572A5tQ/H1e572A5tQ.md +233 -0
- md/train/H1laeJrKDB/H1laeJrKDB.md +337 -0
- md/train/H1xFWgrFPS/H1xFWgrFPS.md +341 -0
- md/train/H1xQVn09FX/H1xQVn09FX.md +256 -0
- md/train/HHiiQKWsOcV/HHiiQKWsOcV.md +0 -0
- md/train/HJl6tC4KwB/HJl6tC4KwB.md +260 -0
- md/train/HJlmHoR5tQ/HJlmHoR5tQ.md +400 -0
- md/train/HJx9EhC9tQ/HJx9EhC9tQ.md +250 -0
- md/train/HkNKFiGex/HkNKFiGex.md +260 -0
- md/train/HkgH0TEYwH/HkgH0TEYwH.md +458 -0
- md/train/HyGh4sR9YQ/HyGh4sR9YQ.md +307 -0
- md/train/Hyl5V0EYvB/Hyl5V0EYvB.md +416 -0
- md/train/HyxzRsR9Y7/HyxzRsR9Y7.md +417 -0
- md/train/S1g2V3Cct7/S1g2V3Cct7.md +256 -0
- md/train/S1gBz2C9tX/S1gBz2C9tX.md +410 -0
- md/train/SkfhIo0qtQ/SkfhIo0qtQ.md +612 -0
- md/train/Skgvy64tvr/Skgvy64tvr.md +0 -0
- md/train/UEtNMTl6yN/UEtNMTl6yN.md +240 -0
- md/train/Z2vksUFuVst/Z2vksUFuVst.md +344 -0
- md/train/aJh-lFL2dFJ21/aJh-lFL2dFJ21.md +216 -0
- md/train/bM3L3I_853/bM3L3I_853.md +304 -0
- md/train/gwPPcc_M0lv/gwPPcc_M0lv.md +481 -0
- md/train/jNTeYscgSw8/jNTeYscgSw8.md +390 -0
- md/train/kN4mGdGWc92/kN4mGdGWc92.md +542 -0
- md/train/r1lIKlSYvH/r1lIKlSYvH.md +592 -0
- md/train/rJLS7qKel/rJLS7qKel.md +298 -0
- md/train/rJTutzbA-/rJTutzbA-.md +682 -0
- md/train/rJwelMbR-/rJwelMbR-.md +296 -0
- md/train/rJxDkvqee/rJxDkvqee.md +279 -0
- md/train/rkxaNjA9Ym/rkxaNjA9Ym.md +0 -0
- md/train/ry8dvM-R-/ry8dvM-R-.md +307 -0
- md/train/rylT0AVtwH/rylT0AVtwH.md +418 -0
- md/train/rywHCPkAW/rywHCPkAW.md +407 -0
- md/train/tkAtoZkcUnm/tkAtoZkcUnm.md +0 -0
- md/train/tyd9yxioXgO/tyd9yxioXgO.md +400 -0
- md/train/vlcVTDaufN/vlcVTDaufN.md +245 -0
- md/train/wTutcPE7zOC/wTutcPE7zOC.md +444 -0
- md/train/x8gM-4nFq9b/x8gM-4nFq9b.md +441 -0
md/train/14nC8HNd4Ts/14nC8HNd4Ts.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SYNTHESISING REALISTIC CALCIUM TRACES OF NEURONAL POPULATIONS USING GAN
|
| 2 |
+
|
| 3 |
+
Anonymous authors Paper under double-blind review
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
Calcium imaging has become a powerful and popular technique to monitor the activity of large populations of neurons in vivo. However, for ethical considerations and despite recent technical developments, recordings are still constrained to a limited number of trials and animals. This limits the amount of data available from individual experiments and hinders the development of analysis techniques and models for more realistic sizes of neuronal populations. The ability to artificially synthesize realistic neuronal calcium signals could greatly alleviate this problem by scaling up the number of trials. Here, we propose a Generative Adversarial Network (GAN) model to generate realistic calcium signals as seen in neuronal somata with calcium imaging. To this end, we propose CalciumGAN, a model based on the WaveGAN architecture and train it on calcium fluorescent signals with the Wasserstein distance. We test the model on artificial data with known ground-truth and show that the distribution of the generated signals closely resembles the underlying data distribution. Then, we train the model on real calcium traces recorded from the primary visual cortex of behaving mice and confirm that the deconvolved spike trains match the statistics of the recorded data. Together, these results demonstrate that our model can successfully generate realistic calcium traces, thereby providing the means to augment existing datasets of neuronal activity for enhanced data exploration and modelling.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
The ability to record accurate neuronal activities from behaving animals is essential for the study of information processing in the brain. Electrophysiological recording, which measures the rate of change in voltage by microelectrodes inserted in the cell membrane of a neuron, has high temporal resolution and is considered the most accurate method to measure spike activities (Dayan & Abbott, 2001). However, this method is not without shortcomings (Harris et al., 2016). For instance, a single microelectrode can only detect activity from few neurons in close proximity, and extensive pre-processing is required to infer single-unit activity from a multi-unit signal. Disentangling circuit computations in neuronal populations of a large scale remains a difficult task (Rey et al., 2015). On the other hand, calcium imaging monitors the calcium influx in the cell as a proxy of an action potential (Berridge et al., 2000). Contrary to electrophysiological recordings, this technique yields data with high spatial resolution and low temporal resolution (Grienberger & Konnerth, 2012), and has become a powerful imaging technique to monitor large neuronal populations. With the advancements in these recording technologies, it has become increasingly easier to obtain high-quality neuronal activity data in vivo from live animals. However, due to ethical considerations, the acquired datasets are often limited by the number of trials or the duration of each trial on a live animal. This poses a problem for assessing analysis techniques that take into account higher-order correlations (Brown et al., 2004; Staude et al., 2010; Stevenson & Kording, 2011; Saxena & Cunningham, 2019). Even for linear decoders, the number of trials can be more important for determining coding accuracy than the number of neurons (Stringer et al., 2019).
|
| 12 |
+
|
| 13 |
+
Generative models of neuronal activity hold the promise of alleviating the above problem by enabling the synthesis of an unlimited number of realistic samples for assessing advanced analysis methods. Popular modelling approaches such as the maximum entropy framework (Schneidman et al., 2006; Tkacik et al., 2014) and the latent variable model (Macke et al., 2009; Lyamzin et al., ˇ 2010) have shown ample success in modelling spiking activities, though many of these models require strong assumptions on the data and cannot generalize to different cortical areas. To this end, GANs have shown tremendous success in synthesizing data across a vast variety of domains and data-types (Karras et al., 2017; Gomez et al., 2018; Donahue et al., 2019), and are good candidates for modelling neuronal activities. Spike-GAN (Molano-Mazon et al., 2018) demonstrated that GANs can model neural spikes that accurately match the statistics of real recorded spiking behaviour from a small number of neurons. Moreover, the discriminator in Spike-GAN is able to learn to detect which population activity pattern is the relevant feature, and this can provide insights into how a population of neurons encodes information. Ramesh et al. (2019) trained a conditional GAN (Mirza & Osindero, 2014), conditioned on the stimulus, to generate multivariate binary spike trains. They fitted the generative model with data recorded in the V1 area of macaque visual cortex, and the GAN generated spike trains were able to capture the firing rate and pairwise correlation statistics better than the dichotomized Gaussian model (Macke et al., 2009) and a deep supervised convolution model.
|
| 14 |
+
|
| 15 |
+
Nevertheless, the aforementioned deep generative models operate on spike trains which are discrete in nature, and back-propagation on discrete data remains a difficult task (Caccia et al., 2018). For instance, Ramesh et al. (2019) used the REINFORCE gradient estimate (Williams, 1992) to train the generator in order to perform back-propagation on discrete data. Still, gradient estimation with the REINFORCE approach yields large variance, which is known to be challenging for optimization (Maddison et al., 2016; Zhang et al., 2017). In addition, generating and training on binary spike trains directly introduces uncertainty as the generator has to learn the deconvolution process as well, making it an even more difficult task.
|
| 16 |
+
|
| 17 |
+
In this work, we investigate the possibility of synthesising continuous calcium fluorescent signals using the GAN framework, as a method to scale-up or augment the amount of population activity data. In addition, modelling the calcium signals directly has several advantages (a) the generator needs to learn the deconvolution process when synthesising directly on binary spike trains, hence there is additional uncertainty, which is not present for calcium signals. (b) Calcium imaging signals have inherently more information about the neuronal activities than binary spike trains. (c) Based on calcium signals with known ground-truth, calcium deconvolution algorithms can be evaluated. Hence, We devised a workflow to synthesize and evaluate calcium imaging signals, then validate the method on artificial data with known ground-truth as well as mimicking real two-photon calcium $( \mathrm { C a ^ { 2 + } } )$ imaging data as recorded from the primary visual cortex of a behaving mouse (Pakan et al., 2018; Henschke et al., 2020).
|
| 18 |
+
|
| 19 |
+
# 2 METHODS
|
| 20 |
+
|
| 21 |
+
# 2.1 NETWORK ARCHITECTURE
|
| 22 |
+
|
| 23 |
+
The original GAN framework, introduced in Goodfellow et al. (2014), plays a min-max game where the generator $G$ attempts to generate convincing samples from the latent space $Z$ , and the discriminator $D$ learns to distinguish between generated samples and real samples $X$ . In this work, we use the WGAN-GP (Gulrajani et al., 2017) formulation of the loss function without the need of incorporating any information of the neural activities into the training objective:
|
| 24 |
+
|
| 25 |
+
$$
|
| 26 |
+
\mathcal { L } _ { D } = \underset { z \sim Z } { \mathbb { E } } [ D ( G ( z ) ) ] - \underset { x \sim X } { \mathbb { E } } [ D ( x ) ] + \lambda \underset { \tilde { x } \sim \tilde { X } } { \mathbb { E } } [ ( \| \nabla _ { \tilde { x } } D ( \tilde { x } ) \| _ { 2 } - 1 ) ^ { 2 } ]
|
| 27 |
+
$$
|
| 28 |
+
|
| 29 |
+
where $\lambda$ denotes the gradient penalty coefficient, $\tilde { x } = \epsilon x + ( 1 - \epsilon ) \hat { x }$ are samples taken between the real and generated data distribution.
|
| 30 |
+
|
| 31 |
+
For learning calcium signal generation, we adapted the WaveGAN architecture (Donahue et al., 2019), which has shown promising results in audio signal generation. In the generator, we used 1-dimensional transposed convolution layers to up-sample the input noise. We added Layer Normalization (Ioffe & Szegedy, 2015) in between each convolution and activation layer, in order to stabilize training as well as to make the operation compatible with the WGAN-GP framework. To improve the model learning performance and stability, the calcium signals were scaled to the range between 0 and 1 by normalizing with the maximum value of the calcium signal in the data. Correspondingly, we chose sigmoid activation in the output layer of the generator and then re-scaled the signals to their original range before inferring their spike trains.
|
| 32 |
+
|
| 33 |
+
The architecture of the discriminator in our model is largely a mirror of the generator, with the exception of the removal of Layer Normalization and instead of up-sampling the input with transposed convolution, we used a simple convolution layer. Samples generated using transposed convolution often exhibit the ”checkerboard” artifacts described by Odena et al. (2016), where the output exhibits repeated patterns (usually very subtle to the eye) due to a filter being applied unevenly to the receptive field. In the context of signal generation, the discrimination could exploit the periodic artifacts pattern and learn a naive policy to reject generated samples. Donahue et al. (2019) proposed the Phase Shuffle mechanism in the discriminator to address the aforementioned issue. The Phase Shuffle layer randomly shifts the activated units after each convolution layer within $[ - n , n ]$ , in order to distort the periodic pattern. Hence, the resulting samples constitute a more challenging task for the discriminator. Figure A.4 shows a simple illustration of the Phase Shuffle operation. In our network, we incorporated the Phase Shuffle operation, as well as using a kernel size that is divisible by the stride size, as suggested in Odena et al. (2016). We apply the Phase Shuffle operation after each convolution layer, which has led to a noticeable improvement in the generated samples. Table A.1 shows the exact architecture of our model.
|
| 34 |
+
|
| 35 |
+
# 2.2 MODEL PIPELINE
|
| 36 |
+
|
| 37 |
+
We devised a consistent model analysis pipeline to evaluate the quality of samples generated by the model, as well as its ability to generalize, in the context of neuronal population spiking activities. The complete model analysis pipeline is shown in Figure A.2.
|
| 38 |
+
|
| 39 |
+
As calcium imaging is largely being used as a proxy to monitor spiking activities, we have decided to evaluate and present the inferred spike trains instead of raw calcium signals. We used the Online Active Set method to Infer Spikes (OASIS) AR1 deconvolution algorithm (Friedrich et al., 2017) to infer spiking activities from calcium fluorescent signals. We apply OASIS to both the training data and generated data to ensure the potential bias in the deconvolution process applies to the two sets of data. We then trained both the generator and discriminator with the WGAN-GP framework (Gulrajani et al., 2017), with 5 discriminator update steps for each generator update step. We used the Adam optimizer (Kingma & Ba, 2014) to optimize both networks, with a learning rate of $\lambda = 1 0 ^ { - 4 }$ , $\beta _ { 1 } = 0 . 9$ and $\beta _ { 2 } = 0 . 9 9 9 9$ . To speed up the training process, we incorporated Mixed Precision training (Micikevicius et al., 2017) in our codebase. The exact hyper-parameters being used in this work can be found in Table A.2.
|
| 40 |
+
|
| 41 |
+
After inferring the spike trains from the generated calcium signals, we then measure the spike train statistics and similarities using the Electrophysiology Analysis Toolkit (Denker et al., 2018). Following some of the previous works in spike generation (Macke et al., 2009; Molano-Mazon et al., 2018; Ramesh et al., 2019), we evaluate the performance of our model with the following statistics and similarities: (a) mean firing rate for evaluating single neuron statistics; (b) pairwise Pearson correlation coefficient for evaluating pairwise statistics; (c) pairwise van-Rossum distance (Rossum, 2001) for evaluating general spike train similarity. Importantly, we evaluate these quantities across the whole population for each neuron or neuron pair and each short time interval $\mathrm { 1 0 0 m s ) }$ and compare the resulting distributions over these quantities obtained from training data as well as generated data. We therefore validate the whole spatiotemporal first- and second-order statistics as well as general spike train similarities.
|
| 42 |
+
|
| 43 |
+
# 2.3 DATA
|
| 44 |
+
|
| 45 |
+
# 2.3.1 DICHOTOMIZED GAUSSIAN ARTIFICIAL DATA
|
| 46 |
+
|
| 47 |
+
In order to verify that CalciumGAN is able to learn the underlying distribution and statistics of the training data, we generated our own ground-truth dataset with pre-defined mean and covariance using the dichotomized Gaussian (DG) model (Macke et al., 2009). The model uses a multivariate normal distribution to generate latent continuous random variables which are then thresholded to generate binary variables representing spike trains. The DG model has mean vector and covariance matrix as free parameters. To generate data from this model, we used the sample means and sample covariances obtained from real recorded data (see Section 2.3.2). In alignment with the recorded data, we generated correlated spike trains for $N = 1 0 2$ neurons with a duration of 899 seconds and at $2 4 \mathrm { H z }$ , hence a matrix with shape (21576, 102). In order to obtain calcium-like signals $c$ from spike trains $s$ with length $T$ , we convolved the generated spike trains with a calcium response kernel and added noise, as described in Friedrich et al. (2017):
|
| 48 |
+
|
| 49 |
+
$$
|
| 50 |
+
\begin{array} { r l } { s _ { t } = g s _ { t - 1 } + s _ { t } \quad } & { { } 1 \leq t \leq T } \\ { c = b + s + \sigma u \quad } & { { } u \sim \mathcal { N } ( 0 , 1 ) } \end{array}
|
| 51 |
+
$$
|
| 52 |
+
|
| 53 |
+
where $g$ denotes a finite impulse response filter, $b$ is the baseline value of the signal and $\sigma$ is the noise standard deviation. In our work, we set $g = 0 . 9 5$ , $\sigma = 0 . 3$ and $b = 0$ . We scale the signal range to the unit interval. The data is then segmented using a sliding window along the time dimension with a stride of 2 and a window size of $T = 2 0 4 8$ (around 85 seconds in experiment time). We apply the segmentation procedure to both the signal and spike data, hence resulting in two matrices with shape (9754, 2048, 102). Examples of signals and spikes generated from the DG model can be found in Figure A.1a.
|
| 54 |
+
|
| 55 |
+
# 2.3.2 TWO-PHOTON CALCIUM IMAGING RECORDED DATA
|
| 56 |
+
|
| 57 |
+
Next, we used two-photon calcium imaging data recorded in the primary visual cortex of behaving mice. The data were collected with the same setup as specified in Pakan et al. (2018) and Henschke et al. (2020). Head-fixed mice were placed on a cylindrical treadmill, and navigated a virtual corridor rendered on two monitors that covered the majority of their visual field. A lick spout was placed in front of the mice, where a water drop would be made available to the mice as a reward if it licked at the correct location within the virtual environment. Hence, the mice would learn to utilize both the visual information and the self-motion feedback in order to maximize the rewards. Neuronal activity was monitored from the same primary visual cortex populations over multiple consecutive behavioural sessions. The basic characteristics of the recorded data are shown in Table A.3. We first experiment with calcium imaging data recorded on the $4 ^ { \mathrm { t h } }$ day of the experiment, where the mice were familiar with the virtual environment and the given task. In this particular recording, neurons were labelled with GCamP6f, and $N = 1 0 2$ neurons were recorded at a sampling rate of $2 4 \mathrm { H z }$ , and the mouse performed 204 trials in 898.2 seconds (raw data shape (21556, 102)). Due to the fact that GAN models require a significant amount of training data, information about the trial and position of the mouse in the virtual environment were not used in this work.
|
| 58 |
+
|
| 59 |
+
# 3 RESULTS
|
| 60 |
+
|
| 61 |
+
We propose CalciumGAN as a generative model to synthesize realistic calcium traces as imaged from neuronal populations. To validate our model, we used artificial data with known groundtruth as well as real data recorded from the primary visual cortex of behaving mice. We used the WGAN-GP training objective (Section 2.1) to train both the generator and discrminator. We have also experimented with the objective function from the original GAN (Goodfellow et al., 2014) and LSGAN (Mao et al., 2017). From our experiments, the WGAN-GP formulation had the best training performance and stability.
|
| 62 |
+
|
| 63 |
+
# 3.1 SYNTHETIC DATA MIMICKING DICHOTOMIZED GAUSSIAN DATA
|
| 64 |
+
|
| 65 |
+
We first fit our model with the artificial dataset sampled from the DG distribution. We trained the model for 400 epochs with 8,754 samples and held out 1,000 samples for evaluation. Since we defined the model from which we generated the training dataset, we can validate the statistics of the dataset generated by CalciumGAN on the known ground-truth directly. Examples of generated signals and its inferred spikes can be found in Figure A.1b.
|
| 66 |
+
|
| 67 |
+
Here, we compare both the trend and variation of the generated data statistics with the DG data. We estimated the mean firing rates and the covariances of data generated by CalciumGAN and compared it to the DG ones (Figure 1). We plotted the values of 5 samples for each neuron and neuron-pair, and sorted them by their mean in ascending order. The variation of the firing rate across samples matched with those of the ground-truth data. The majority of the neuron pairs have low correlation, a characteristic which was also found in the generated data. The neuron pairs that have highly positive and highly negative covariance also have a greater variation across samples.
|
| 68 |
+
|
| 69 |
+

|
| 70 |
+
Figure 1: CalciumGAN trained on the dichotomized Gaussian dataset with known ground-truth. (a) Mean firing rate of each neuron. (b) Neuron pairwise covariance. Blue dots represent DG data and orange crosses present generated data. 5 randomly selected samples for each neuron and neuronpair were displayed in both graphs, where the order on the $\mathbf { X }$ -axis was sorted by the mean of the firing rate and covariance respectively. In (b), only every $1 0 ^ { \mathrm { t h } }$ pair is displayed for clarity.
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
Figure 2: Calcium signals and inferred spike trains (in gray) of randomly selected neurons. (a) shows the recorded data (in blue) and (b) shows synthetic data (in orange) generated by CalciumGAN trained on recorded data. Note: the generated data should not be identical with the recorded data, because CalciumGAN should not replicate the signals.
|
| 74 |
+
|
| 75 |
+
# 3.2 SYNTHETIC DATA MIMICKING RECORDED DATA
|
| 76 |
+
|
| 77 |
+
After validating our model on data with known ground-truth, we applied CalciumGAN on twophoton calcium imaging data recorded in the primary visual cortex of mice performing a virtual reality task. We applied the OASIS deconvolution algorithm to infer the spike activities from the recorded calcium signals, and performed the same normalization and segmentation steps as mentioned in Section 2.3.1. Figure 2a shows examples of the recorded calcium signals and inferred spike trains. There are multiple challenges for both the generator and discriminator to learn from the calcium imaging signals. Since data were segmented with a sliding window and the information of the trial was not used, some samples might consist of abnormal signal activity, such as a peak being cropped off. Generated signals could have the same number of peaks or ranges, though might not preserve the peak and decay characteristics of calcium imaging data. Real and synthetic activity from less active neurons might be more difficult for the discriminator to distinguish due to the absence of prominent spiking characteristics.
|
| 78 |
+
|
| 79 |
+
Similar to the DG analysis, we trained the model for 400 epochs, with 8,754 training samples, and 1,000 samples were held out for evaluation. Note that since we are not taking the trial and position of the mice in the virtual environment into consideration when training the model, the generated data and the evaluation data do not have a one-to-one mapping.
|
| 80 |
+
|
| 81 |
+

|
| 82 |
+
Figure 3: Raster plot of inferred real and synthetic spike trains of a randomly selected sample generated by CalciumGAN trained on recorded data. Blue markers indicate recorded data and orange markers indicate generated data. The histograms on the $x$ and $y$ axis indicate number of spikes over the temporal dimension and neuron population respectively.
|
| 83 |
+
|
| 84 |
+
We first inspect the generated data and the deconvolved spike trains visually. The calcium signals and inferred spike trains of randomly selected neurons from a randomly selected sample are shown in Figure 2b. Both the synthetic raw traces as well as the inferred spikes visually match the characteristics of the recorded ones.
|
| 85 |
+
|
| 86 |
+
We then compared the spiking characteristics across the whole population. Figure 3 shows the inferred spike trains of the complete 102 neurons population from a randomly selected sample of the real and the synthetic data, with the distribution histogram plotted on the $x$ and $y$ axis. The synthetic data mimicks the firing patterns across neurons and across time remarkably well with occasional small deviations in the rates at particular temporal intervals. Notably, the samples are clearly not identical meaning that the network did not just replicate the training set data.
|
| 87 |
+
|
| 88 |
+
In order to examine if CalciumGAN is able to capture the first and second order statistics of the recorded data, we measured the mean firing rate, pairwise correlation, and van-Rossum distance (see Figure 4). The randomly selected neurons shown in Figure 4a have very distinct firing rate distributions, and CalciumGAN is able to model all of them relatively well, with KL divergence of
|
| 89 |
+
|
| 90 |
+

|
| 91 |
+
Figure 4: First and second order statistics of data generated from CalciumGAN trained on the recorded data. Shown neurons and samples were randomly selected. (a) Mean firing rate distribution over 1000 samples per neuron. (b) Pearson correlation coefficient distribution. (c) van-Rossum distance between recorded and generated spike trains over 45 samples. Heatmaps were sorted where the pair with the smallest distance value was placed at the top left corner, followed by the pair with the second smallest distance at the second row second column, and so on.
|
| 92 |
+
|
| 93 |
+

|
| 94 |
+
Figure 5: KL divergence of the (a) mean firing rate, (b) pairwise correlation and (c) pairwise vanRossum distance between 1,000 recorded and generated samples.
|
| 95 |
+
|
| 96 |
+
0.31 and 0.16 with respect to the recorded firing rate over 1000 samples. We show the pairwise van-Rossum distance of the same neuron between recorded and generated data across 45 samples in Figure 4c as sorted heatmaps. Less active neurons, such as neuron 75, have a low distance value across samples, mainly due to the scarcity of firing events. Conversely, a high frequency neuron, such as neuron 27, exhibits a clear trend of lower distance values in the diagonal of the heatmap, implying the existence of a pair of recorded and generated sample that are similar. In order to ensure that the data generated by our model capture the underlying distribution of the training data, we also compute the KL divergence between the distributions of the above-mentioned metrics (see Figure 5). Note that we measure the pairwise distance of the same neuron across 50 samples in Figure 4c, whereas in Figure 5c, we measure pairwise van-Rossum distance of each neuron with respect to other neurons within the same sample. We also fitted the DG model to the recorded data
|
| 97 |
+
|
| 98 |
+
and measure the same statistics on the DG generated spike trains as a baseline. Table 1 shows the mean KL divergence of the generated data from CalciumgGAN, CalciumGAN with Phase Shuffle disabled (see Appendix A.2) and the DG model.
|
| 99 |
+
|
| 100 |
+
<table><tr><td>Model</td><td>mean firing rate</td><td></td><td>丨pairwise correlation|van-Rossum distance</td></tr><tr><td>CalciumGAN</td><td>0.4533</td><td>0.0821</td><td>0.5757</td></tr><tr><td>- without Phase Shuffle</td><td>1.0170</td><td>0.1027</td><td>0.7787</td></tr><tr><td>DG</td><td>1.0592</td><td>0.3379</td><td>1.0287</td></tr></table>
|
| 101 |
+
|
| 102 |
+
Table 1: The mean KL divergence value in each metrics of different models.
|
| 103 |
+
|
| 104 |
+
The results we presented above were trained on recordings collected from a mouse that was already familiar with the specific task. However, we were also interested in our model’s capability to learn from neuronal activities that are more stochastic and potentially less correlated. To this end, we trained CalciumGAN on data recorded on the first day of the experiment (average firing rate of $5 8 . 0 7 \mathrm { H z }$ on day 1 versus $3 5 . 8 3 \mathrm { H z }$ on day 4, see Table A.3). Appendix A.3 shows the generated samples and the statistics of the inferred spike trains. The generated data were able to reflect the first and second-order statistics of the recorded data, with mean KL divergence of 0.32, 0.06 and 0.51 when comparing with the mean firing rate, pairwise correlation and van-Rossum distance, respectively. Overall, CalciumGAN was able to capture the statistics and underlying distribution of the real calcium imaging data acquired in the primary visual cortex of awake, behaving mice.
|
| 105 |
+
|
| 106 |
+
# 4 DISCUSSION
|
| 107 |
+
|
| 108 |
+
Despite the recent advancement and popularity of calcium imaging of neuronal activity in vivo, the number of trials and the duration of imaging sessions in animal experiments is limited due to ethical and practical considerations. This work provides a readily applicable tool to fit a GAN on calcium signals, enabling the generation of more data that matches the statistics of the provided data.
|
| 109 |
+
|
| 110 |
+
We demonstrated that the GAN framework is capable of synthesizing realistic calcium fluorescent signals similar to those imaged in the somata of neuronal populations of behaving animals. To achieve this, we adapted the WaveGAN (Donahue et al., 2019) architecture with the Wasserstein distance training objective. We generated artificial neuronal activities using a dichotomized Gaussian model, showing that CalciumGAN is able to learn the underlying distribution of the data. We then fitted our model to imaging data from the primary visual cortex of a behaving mouse. Importantly, we showed that the statistics of the synthetic spike trains match the statistics of the recorded data, without the need of incorporating any information of the neuronal activities into the model or the objective function.
|
| 111 |
+
|
| 112 |
+
We would like to highlight one potential bias in this work. To infer spike trains from the real and synthetic calcium traces, we used the OASIS deconvolution algorithm by Friedrich et al. (2017), a method which has great real-time deconvolution performance, as well as an existing Python implementation of the algorithm by the authors (Friedrich, 2017). Speed was a crucial characteristic for evaluating a large number of trials. Nonetheless, we found that this advantage often came at the cost of performance in the form of clearly missed spikes (c.f. Figure 2). However, we stress that these shortcomings apply to both the real data and the synthetic data in exactly the same way. In the end, we use the inferred spikes as a way to validate the plausibility of the synthesized traces. The comparison is fair as long as real and synthetic deconvolutions are subject to the same biases.
|
| 113 |
+
|
| 114 |
+
As the work in deep generative models continue to develop and expand, there is a limitless number of possibilities to explore at the intersection of the GAN framework and neural coding. One potential future direction for this work is to provide a meaningful interpretation for the latent generator representation. In many image generation tasks with GANs (Bojanowski et al., 2017; Karras et al., 2017) it has been shown that the output image can be modified or targeted by interpolating the latent variable that is fed to the generator. Similarly, one could potentially have final control of the generated calcium signals by exploring the synthetic calcium signals generated after interpolating samples in the latent space. Thereby, one could generate calcium imaging data that resemble the neuronal activities of an animal performing a particular novel task. Another interesting research direction would be using a GAN to learn the relationship between different neuronal populations, or to reveal changes in activity of the same neuronal population in different training phases of an animal learning a behavioral task. This could be achieved by using, for instance, CycleGAN (Zhu et al., 2017), an unsupervised learning model that can learn the mapping between two distributions without paired data, as a potential model architecture.
|
| 115 |
+
|
| 116 |
+
# REFERENCES
|
| 117 |
+
|
| 118 |
+
Michael J Berridge, Peter Lipp, and Martin D Bootman. The versatility and universality of calcium signalling. Nature reviews Molecular cell biology, 1(1):11–21, 2000.
|
| 119 |
+
|
| 120 |
+
Piotr Bojanowski, Armand Joulin, David Lopez-Paz, and Arthur Szlam. Optimizing the latent space of generative networks. arXiv preprint arXiv:1707.05776, 2017.
|
| 121 |
+
|
| 122 |
+
Emery N Brown, Robert E Kass, and Partha P Mitra. Multiple neural spike train data analysis: state-of-the-art and future challenges. Nature neuroscience, 7(5):456–461, 2004.
|
| 123 |
+
|
| 124 |
+
Massimo Caccia, Lucas Caccia, William Fedus, Hugo Larochelle, Joelle Pineau, and Laurent Charlin. Language gans falling short. arXiv preprint arXiv:1811.02549, 2018.
|
| 125 |
+
|
| 126 |
+
Peter Dayan and Laurence F Abbott. Theoretical neuroscience: computational and mathematical modeling of neural systems. 2001.
|
| 127 |
+
|
| 128 |
+
M. Denker, A. Yegenoglu, and S. Grun. Collaborative HPC-enabled workflows on the HBP Col- ¨ laboratory using the Elephant framework. In Neuroinformatics 2018, pp. P19, 2018. doi: 10.12751/incf.ni2018.0019. URL https://abstracts.g-node.org/conference/ NI2018/abstracts#/uuid/023bec4e-0c35-4563-81ce-2c6fac282abd.
|
| 129 |
+
|
| 130 |
+
Chris Donahue, Julian McAuley, and Miller Puckette. Adversarial audio synthesis. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum? id $=$ ByMVTsR5KQ.
|
| 131 |
+
|
| 132 |
+
Johannes Friedrich. Oasis. https://github.com/j-friedrich/OASIS, 2017.
|
| 133 |
+
|
| 134 |
+
Johannes Friedrich, Pengcheng Zhou, and Liam Paninski. Fast online deconvolution of calcium imaging data. PLoS computational biology, 13(3):e1005423, 2017.
|
| 135 |
+
|
| 136 |
+
Flavio Frohlich. Chapter 11 - optical measurements and perturbations. In Flavio Fr ¨ ohlich (ed.), ¨ Network Neuroscience, pp. 145 – 159. Academic Press, San Diego, 2016. ISBN 978-0-12- 801560-5. doi: https://doi.org/10.1016/B978-0-12-801560-5.00011-2. URL http://www. sciencedirect.com/science/article/pii/B9780128015605000112.
|
| 137 |
+
|
| 138 |
+
Aidan N Gomez, Sicong Huang, Ivan Zhang, Bryan M Li, Muhammad Osama, and Lukasz Kaiser. Unsupervised cipher cracking using discrete gans. arXiv preprint arXiv:1801.04883, 2018.
|
| 139 |
+
|
| 140 |
+
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Z. Ghahramani, M. Welling, C. Cortes, N. D. Lawrence, and K. Q. Weinberger (eds.), Advances in Neural Information Processing Systems 27, pp. 2672–2680. Curran Associates, Inc., 2014. URL http://papers. nips.cc/paper/5423-generative-adversarial-nets.pdf.
|
| 141 |
+
|
| 142 |
+
Christine Grienberger and Arthur Konnerth. Imaging calcium in neurons. Neuron, 73(5):862–885, 2012.
|
| 143 |
+
|
| 144 |
+
Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. In Advances in neural information processing systems, pp. 5767–5777, 2017.
|
| 145 |
+
|
| 146 |
+
Kenneth D Harris, Rodrigo Quian Quiroga, Jeremy Freeman, and Spencer L Smith. Improving data quality in neuronal population recordings. Nature neuroscience, 19(9):1165, 2016.
|
| 147 |
+
|
| 148 |
+
Julia U Henschke, Evelyn Dylda, Danai Katsanevaki, Nathalie Dupuy, Stephen P Currie, Theoklitos Amvrosiadis, Janelle MP Pakan, and Nathalie L Rochefort. Reward association enhances stimulus-specific representations in primary visual cortex. Current Biology, 2020.
|
| 149 |
+
|
| 150 |
+
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015.
|
| 151 |
+
|
| 152 |
+
Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. arXiv preprint arXiv:1710.10196, 2017.
|
| 153 |
+
|
| 154 |
+
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
|
| 155 |
+
|
| 156 |
+
Dmitry R Lyamzin, Jakob H Macke, and Nicholas A Lesica. Modeling population spike trains with specified time-varying spike rates, trial-to-trial variability, and pairwise signal and noise correlations. Frontiers in computational neuroscience, 4:144, 2010.
|
| 157 |
+
|
| 158 |
+
Jakob H Macke, Philipp Berens, Alexander S Ecker, Andreas S Tolias, and Matthias Bethge. Generating spike trains with specified correlation coefficients. Neural computation, 21(2):397–423, 2009.
|
| 159 |
+
|
| 160 |
+
Chris J. Maddison, Andriy Mnih, and Yee Whye Teh. The concrete distribution: A continuous relaxation of discrete random variables, 2016.
|
| 161 |
+
|
| 162 |
+
Xudong Mao, Qing Li, Haoran Xie, Raymond YK Lau, Zhen Wang, and Stephen Paul Smolley. Least squares generative adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2794–2802, 2017.
|
| 163 |
+
|
| 164 |
+
Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
|
| 165 |
+
|
| 166 |
+
Mehdi Mirza and Simon Osindero. Conditional generative adversarial nets. arXiv preprint arXiv:1411.1784, 2014.
|
| 167 |
+
|
| 168 |
+
Manuel Molano-Mazon, Arno Onken, Eugenio Piasini\*, and Stefano Panzeri\*. Synthesizing realistic neural population activity patterns using generative adversarial networks. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum? id=r1VVsebAZ.
|
| 169 |
+
|
| 170 |
+
Augustus Odena, Vincent Dumoulin, and Chris Olah. Deconvolution and checkerboard artifacts. Distill, 2016. doi: 10.23915/distill.00003. URL http://distill.pub/2016/ deconv-checkerboard.
|
| 171 |
+
|
| 172 |
+
Janelle MP Pakan, Stephen P Currie, Lukas Fischer, and Nathalie L Rochefort. The impact of visual cues, reward, and motor feedback on the representation of behaviorally relevant spatial locations in primary visual cortex. Cell reports, 24(10):2521–2528, 2018.
|
| 173 |
+
|
| 174 |
+
Poornima Ramesh, Mohamad Atayi, and Jakob H Macke. Adversarial training of neural encoding models on population spike trains. 2019.
|
| 175 |
+
|
| 176 |
+
Hernan Gonzalo Rey, Carlos Pedreira, and Rodrigo Quian Quiroga. Past, present and future of spike sorting techniques. Brain research bulletin, 119:106–117, 2015.
|
| 177 |
+
|
| 178 |
+
MCW van Rossum. A novel spike distance. Neural computation, 13(4):751–763, 2001.
|
| 179 |
+
|
| 180 |
+
Shreya Saxena and John P. Cunningham. Towards the neural population doctrine, 2019. ISSN 18736882.
|
| 181 |
+
|
| 182 |
+
Elad Schneidman, Michael J Berry, Ronen Segev, and William Bialek. Weak pairwise correlations imply strongly correlated network states in a neural population. Nature, 440(7087):1007–1012, 2006.
|
| 183 |
+
|
| 184 |
+
Benjamin Staude, Stefan Rotter, and Sonja Grun. Cubic: cumulant based inference of higher-order ¨ correlations in massively parallel spike trains. Journal of computational neuroscience, 29(1-2): 327–350, 2010.
|
| 185 |
+
|
| 186 |
+
Ian H. Stevenson and Konrad P. Kording. How advances in neural recording affect data analysis. Nature Neuroscience, 14(2):139–142, feb 2011. ISSN 1097-6256. doi: 10.1038/nn.2731. URL http://www.nature.com/articles/nn.2731.
|
| 187 |
+
|
| 188 |
+
Carsen Stringer, Michalis Michaelos, and Marius Pachitariu. High precision coding in visual cortex. bioRxiv, 2019. doi: 10.1101/679324. URL https://www.biorxiv.org/content/ early/2019/11/04/679324.
|
| 189 |
+
|
| 190 |
+
Gasper Tka ˇ cik, Olivier Marre, Dario Amodei, Elad Schneidman, William Bialek, and Michael J ˇ Berry II. Searching for collective behavior in a large network of sensory neurons. PLoS Comput Biol, 10(1):e1003408, 2014.
|
| 191 |
+
|
| 192 |
+
Ronald J Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine learning, 8(3-4):229–256, 1992.
|
| 193 |
+
|
| 194 |
+
Yizhe Zhang, Zhe Gan, Kai Fan, Zhi Chen, Ricardo Henao, Dinghan Shen, and Lawrence Carin. Adversarial feature matching for text generation. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 4006–4015. JMLR. org, 2017.
|
| 195 |
+
|
| 196 |
+
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Proceedings of the IEEE international conference on computer vision, pp. 2223–2232, 2017.
|
| 197 |
+
|
| 198 |
+
# A APPENDIX
|
| 199 |
+
|
| 200 |
+
Table A.1: The generator (a) and discriminator (b) architecture of CalciumGAN. The generator consists of 4,375,740 parameters, and the discriminator consists of 4,110,273 parameters. Note bs denotes batch size.
|
| 201 |
+
|
| 202 |
+
<table><tr><td>Layer</td><td> Output shape</td></tr><tr><td>Input</td><td>(bs,32)</td></tr><tr><td>Dense</td><td>(bs,2048)</td></tr><tr><td>LeakyRelu</td><td>(bs,2048)</td></tr><tr><td>Reshape</td><td>(bs,64,32)</td></tr><tr><td>ConviDTransposed</td><td>(bs,128,320)</td></tr><tr><td>LayerNorm</td><td>(bs,128,320)</td></tr><tr><td>LeakyRelu</td><td>(bs,128,320)</td></tr><tr><td>Conv1DTransposed</td><td>(bs,256,256)</td></tr><tr><td>LayerNorm</td><td>(bs,256,256)</td></tr><tr><td>LeakyRelu</td><td>(bs,256,256)</td></tr><tr><td>Conv1DTransposed</td><td>(bs,512,192)</td></tr><tr><td>LayerNorm</td><td>(bs,512,192)</td></tr><tr><td>LeakyRelu</td><td>(bs,512,192)</td></tr><tr><td>Conv1DTransposed</td><td>(bs,1024, 128)</td></tr><tr><td>LayerNorm</td><td>(bs,1024, 128)</td></tr><tr><td>LeakyRelu</td><td>(bs,1024,128)</td></tr><tr><td>Conv1DTransposed</td><td>(bs,2048,102)</td></tr><tr><td>LayerNorm</td><td>(bs,2048,102)</td></tr><tr><td>LeakyRelu</td><td>(bs,2048,102)</td></tr><tr><td>Dense</td><td>(bs,2048,102)</td></tr><tr><td></td><td></td></tr><tr><td>Sigmoid</td><td>(bs,2048,102)</td></tr></table>
|
| 203 |
+
|
| 204 |
+
(a) Generator architecture
|
| 205 |
+
|
| 206 |
+
<table><tr><td>Layer Input</td><td>Output shape (bs,2048,102)</td></tr><tr><td>Conv1D LeakyRelu PhaseShuffle Conv1D LeakyRelu PhaseShuffle Conv1D LeakyRelu PhaseShuffle Conv1D LeakyRelu PhaseShuffle Conv1D LeakyRelu Flatten Dense</td><td>(bs,1024, 64) (bs,1024, 64) (bs,1024, 64) (bs,512, 128) (bs,512,128) (bs,512,128) (bs,256,192) (bs,256, 192) (bs,256,192) (bs,128,256) (bs, 128,256) (bs,128,256) (bs,64,320) (bs, 64,320) (bs,20480) (bs,1)</td></tr></table>
|
| 207 |
+
|
| 208 |
+
(b) Discriminator architecture
|
| 209 |
+
|
| 210 |
+
Table A.2: Hyperparamters of CalciumGAN.
|
| 211 |
+
|
| 212 |
+
<table><tr><td>Hyper-parameters</td><td>Value</td></tr><tr><td>Filters</td><td>64</td></tr><tr><td>Kernel size Stride</td><td>24 2</td></tr><tr><td>Noise dimension</td><td>32</td></tr><tr><td>Critic updates</td><td>5</td></tr><tr><td>Gradient penalty (入) Batch size (bs)</td><td>10</td></tr><tr><td></td><td>128</td></tr><tr><td>Epochs</td><td>400</td></tr><tr><td>Learning rate</td><td>0.0001</td></tr><tr><td>Phase shuffle (m)</td><td>10</td></tr></table>
|
| 213 |
+
|
| 214 |
+
<table><tr><td>Date</td><td>Duration</td><td></td><td>Num. trials|Avg. trial duration|Avg. firing rate</td><td></td></tr><tr><td>Day 1</td><td>894.73s</td><td>129</td><td>6.94s</td><td>58.07Hz</td></tr><tr><td>Day 4</td><td>898.45 s</td><td>203</td><td>4.43 s</td><td>35.83 Hz</td></tr></table>
|
| 215 |
+
|
| 216 |
+
Table A.3: Information about the neuron population of $N = 1 0 2$ neurons recorded at $2 4 \mathrm { H z }$ from the primary visual cortex of a behaving mouse on the $1 ^ { \mathrm { s t } }$ day and $4 ^ { \mathrm { t h } }$ day of the experiment.
|
| 217 |
+
|
| 218 |
+

|
| 219 |
+
Figure A.1: Calcium signals and inferred spike trains (in gray) of randomly selected neurons. (a) shows the DG data (in blue) and (b) shows synthetic data (in orange) generated by CalciumGAN trained on the DG data. Notice that the artificial signal data transformed from DG spike data do not have the peak and decay characteristics of typical calcium imaging data. Note: the generated data do not incorporate the trial information, hence the generated traces do not correspond to the recorded signal in the plotted example.
|
| 220 |
+
|
| 221 |
+
# A.1 CALCIUMGAN PIPELINE
|
| 222 |
+
|
| 223 |
+
In order to train and evaluate our GAN model, we have to first pre-process the calcium signals so that they have a standardized format. For calcium imaging data of $N$ neurons with a recorded length of $L$ , we would receive a raw data shape of $( L , N )$ . We then used a slicing window of size $T$ to segment the data along the time dimension into $M$ segments (see Figure A.3), resulting in a matrix with shape $( M , T , N )$ . To improve the network training performance, we scale the raw calcium signals $x$ to the range $[ 0 , 1 ]$ before we train our generative model:
|
| 224 |
+
|
| 225 |
+
$$
|
| 226 |
+
x _ { [ 0 , 1 ] } = \frac { x - x _ { \operatorname* { m i n } } } { x _ { \operatorname* { m a x } } - x _ { \operatorname* { m i n } } }
|
| 227 |
+
$$
|
| 228 |
+
|
| 229 |
+
We use $a _ { [ 0 , 1 ] }$ to denote datum $a$ that has a range of $[ 0 , 1 ]$ .
|
| 230 |
+
|
| 231 |
+
After the above pre-processing step, we train CalciumGAN in mini-batches and store 1,000 samples for evaluation. Since we evaluate our model performance in terms of spike activities, we needed a deconvolution algorithm to infer the spike trains from calcium signals. In this work, we used the OASIS deconvolution algorithm (Friedrich et al., 2017) for its fast online deconvolution performance. Prior to inferring the spiking activities from the generated signals ${ \hat { x } } _ { [ 0 , 1 ] }$ , we first have to scale the signal back to the same range as the raw calcium signals:
|
| 232 |
+
|
| 233 |
+
$$
|
| 234 |
+
\hat { x } = \hat { x } _ { [ 0 , 1 ] } ( x _ { \mathrm { m a x } } - x _ { \mathrm { m i n } } ) + x _ { \mathrm { m i n } }
|
| 235 |
+
$$
|
| 236 |
+
|
| 237 |
+
We inferred the spike trains from the generated signals as well as the real recorded data with OASIS in order to ensure the possible biases of the deconvolution algorithm are the same for both data.
|
| 238 |
+
|
| 239 |
+

|
| 240 |
+
Figure A.2: Pipeline diagram of a CalciumGAN analysis. White boxes illustrate data in different processing stages. Blue boxes illustrate analysis steps and techniques.
|
| 241 |
+
|
| 242 |
+

|
| 243 |
+
Figure A.3: Illustration of the sliding window process. The light green and green boxes represent the window with sequence length $T$ along the temporal dimension of the calcium signals. We create our training and validation dataset using a window size of $T = 2 0 4 8$ and stride size of $s = 2$ .
|
| 244 |
+
|
| 245 |
+
# A.2 PHASE SHUFFLE
|
| 246 |
+
|
| 247 |
+

|
| 248 |
+
Figure A.4: Illustration of the 1-dimensional Phase Shuffle mechanism. Each box denotes an activated unit after a convolution layer, and the units are mirrored along the grey dash lines. The large box in light green represents the output of the Phase Shuffle layer with $n = - 2$ .
|
| 249 |
+
|
| 250 |
+
In order to reduce the effect of the ”checkerboard” artifact, we adapted the Phase Shuffle mechanism (see 2.1) in the discriminator. In this section we examine the effectiveness of Phase Shuffle in terms of the visual quality of the generated traces as well as the effect it had on the inferred spike trains. A common characteristic of the calcium indicators when an action potential occur is a sharp onset followed by a slow decay in the signal (Frohlich, 2016). In Figure A.5, we can see that ¨ such characteristic in the calcium traces were more prominent when Phase Shuffle was enabled. We believe that such differences in the generation quality exist mainly because of the repetitive patterns in the transposed convolution layer Odena et al. (2016), since the discriminator can simply distinguish generated samples from real samples by learning if such patterns exists. As the Phase Shuffle mechanism shifts the temporal dimension (by 10 units in our experiment) randomly, it forces the discriminator to learn from other features in the data instead of the ”shortcut” provided by the (undesired) nature of transposed convolution.
|
| 251 |
+
|
| 252 |
+
Moreover, not only did Phase Shuffle affect the visual quality of the generated samples, it also impacted the spike train statistics. The traces generated without Phase Shuffle lack the spiking characteristics, which made it more difficult for the deconvolution algorithm to register a spike in the data, thus increasing the inaccuracy of the inferred spike trains. When comparing the KL divergence of the spike train statistics, the samples generated without Phase Shuffle suffer worse results across the 3 statistics (see Table 1), especially with mean firing rate.
|
| 253 |
+
|
| 254 |
+

|
| 255 |
+
Figure A.5: Generated traces of Neuron 6 from a randomly selected sample with (a) PhaseShuffle $=$ 10 and (b) PhaseShuffle $= 0$ . The sharp rise to peak followed by a tail of decaying signal is less observable in when Phase Shuffle is disabled.
|
| 256 |
+
|
| 257 |
+
# A.3 DAY 1 RECORDINGS
|
| 258 |
+
|
| 259 |
+
The following figures are the generated data and spike train statistics of CalciumGAN trained on the calcium imaging recordings collected on the first day of the mice experiment.
|
| 260 |
+
|
| 261 |
+

|
| 262 |
+
Figure A.6: Calcium signals and inferred spike trains (in gray) of randomly selected neurons. (a) shows the recorded data (in blue) and (b) shows synthetic data (in orange) generated by CalciumGAN trained on recorded data. Note: the generated data do not incorporate the trial information, hence the generated traces do not correspond to the recorded signal in the plotted example.
|
| 263 |
+
|
| 264 |
+

|
| 265 |
+
Figure A.7: Raster plot of inferred real and synthetic spike trains of a randomly selected sample generated by CalciumGAN trained on recorded data from the first day of the mice experiment.
|
| 266 |
+
|
| 267 |
+

|
| 268 |
+
Figure A.8: First and second order statistics of data generated from CalciumGAN trained on the recorded data. Shown neurons and samples were randomly selected. (a) Mean firing rate distribution over 1000 samples per neuron. (b) Pearson correlation coefficient distribution. (c) van-Rossum distance between recorded and generated spike trains over 45 samples.
|
| 269 |
+
|
| 270 |
+

|
| 271 |
+
Figure A.9: KL divergence of recorded data and generated data distributions. (a) mean firing rate of each neuron, (b) pairwise Pearson correlation coefficient and (c) pairwise van-Rossum distance. The mean KL divergence of each statistics are 0.3240, 0.0590 and 0.5106 respectively.
|
md/train/3AOj0RCNC2/3AOj0RCNC2.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GRADIENT PROJECTION MEMORY FOR CONTINUAL LEARNING
|
| 2 |
+
|
| 3 |
+
Gobinda Saha, Isha Garg & Kaushik Roy School of Electrical and Computer Engineering, Purdue University gsaha@purdue.edu, gargi@purdue.edu, kaushik@purdue.edu
|
| 4 |
+
|
| 5 |
+
# ABSTRACT
|
| 6 |
+
|
| 7 |
+
The ability to learn continually without forgetting the past tasks is a desired attribute for artificial learning systems. Existing approaches to enable such learning in artificial neural networks usually rely on network growth, importance based weight update or replay of old data from the memory. In contrast, we propose a novel approach where a neural network learns new tasks by taking gradient steps in the orthogonal direction to the gradient subspaces deemed important for the past tasks. We find the bases of these subspaces by analyzing network representations (activations) after learning each task with Singular Value Decomposition (SVD) in a single shot manner and store them in the memory as Gradient Projection Memory (GPM). With qualitative and quantitative analyses, we show that such orthogonal gradient descent induces minimum to no interference with the past tasks, thereby mitigates forgetting. We evaluate our algorithm on diverse image classification datasets with short and long sequences of tasks and report better or on-par performance compared to the state-of-the-art approaches1.
|
| 8 |
+
|
| 9 |
+
# 1 INTRODUCTION
|
| 10 |
+
|
| 11 |
+
Humans exhibit remarkable ability in continual adaptation and learning new tasks throughout their lifetime while maintaining the knowledge gained from past experiences. In stark contrast, Artificial Neural Networks (ANNs) under such Continual Learning (CL) paradigm (Ring, 1998; Thrun & Mitchell, 1995; Lange et al., 2021) forget the information learned in the past tasks upon learning new ones. This phenomenon is known as ‘Catastrophic Forgetting’ or ‘Catastrophic Interference’ (Mccloskey & Cohen, 1989; Ratcliff, 1990). The problem is rooted in the general optimization methods (Goodfellow et al., 2016) that are being used to encode input data distribution into the parametric representation of the network during training. Upon exposure to a new task, gradient-based optimization methods, without any constraint, change the learned encoding to minimize the objective function with respect to the current data distribution. Such parametric updates lead to forgetting.
|
| 12 |
+
|
| 13 |
+
Given a fixed capacity network, one way to address this problem is to put constraints on the gradient updates so that task specific knowledge can be preserved. To this end, Kirkpatrick et al. (2017), Zenke et al. (2017), Aljundi et al. (2018), Serra et al. (2018) add a penalty term to the objec- \` tive function while optimizing for new task. Such term acts as a structural regularizer and dictates the degree of stability-plasticity of individual weights. Though these methods provide resource efficient solution to the catastrophic forgetting problem, their performance suffer while learning longer task sequence and when task identity is unavailable during inference.
|
| 14 |
+
|
| 15 |
+
Approaches (Lopez-Paz & Ranzato, 2017; Chaudhry et al., 2019a) that store episodic memories of old data essentially solve an optimization problem with ‘explicit’ constraints on the new gradient directions so that losses for the old task do not increase. In Chaudhry et al. (2019b) the performance of old task is retained by taking gradient steps in the average gradient direction obtained from the new data and memory samples. To minimize interference, Farajtabar et al. (2020) store gradient directions (instead of data) of the old tasks and optimize the network in the orthogonal directions to these gradients for the new task, whereas Zeng et al. (2018) update gradients orthogonal to the old input directions using projector matrices calculated iteratively during training. However, these methods either compromise data privacy by storing raw data or utilize resources poorly, which limits their scalability.
|
| 16 |
+
|
| 17 |
+
In this paper, we address the problem of catastrophic forgetting in a fixed capacity network when data from the old tasks are not available. To mitigate forgetting, our approach puts explicit constraints on the gradient directions that the optimizer can take. However, unlike contemporary methods, we neither store old gradient directions nor store old examples for generating reference directions. Instead we propose an approach that, after learning each task, partitions the entire gradient space of the weights into two orthogonal subspaces: Core Gradient Space (CGS) and Residual Gradient Space (RGS) (Saha et al., 2020). Leveraging the relationship between the input and the gradient spaces, we show how learned representations (activations) form the bases of these gradient subspaces in both fully-connected and convolutional networks. Using Singular Value Decomposition (SVD) on these activations, we show how to obtain the minimum set of bases of the CGS by which past knowledge is preserved and learnability for the new tasks is ensured. We store these bases in the memory which we define as Gradient Projection Memory (GPM). In our method, we propose to learn any new task by taking gradient steps in the orthogonal direction to the space (CGS) spanned by the GPM. Our analysis shows that such orthogonal gradient descent induces minimum to no interference with the old learning, and thus effective in alleviating catastrophic forgetting. We evaluate our approach in the context of image classification with miniImageNet, CIFAR-100, PMNIST and sequence of 5-Datasets on a variety of network architectures including ResNet. We compare our method with related state-of-the-art approaches and report comparable or better classification performance. Overall, we show that our method is memory efficient and scalable to complex dataset with longer task sequence while preserving data privacy.
|
| 18 |
+
|
| 19 |
+
# 2 RELATED WORKS
|
| 20 |
+
|
| 21 |
+
Approaches to continual learning for ANNs can be broadly divided into three categories. In this section we present a detailed discussion on the representative works from each category, highlighting their contributions and differences with our approach.
|
| 22 |
+
|
| 23 |
+
Expansion-based methods: Methods in this category overcome catastrophic forgetting by dedicating different subsets of network parameters to each task. With no constraint on network architecture, Progressive Neural Network (PGN) (Rusu et al., 2016) preserves old knowledge by freezing the base model and adding new sub-networks with lateral connections for each new task. Dynamically Expandable Networks (DEN) (Yoon et al., 2018) either retrains or expands the network by splitting/duplicating important units on new tasks, whereas Sarwar et al. (2020) grow the network to learn new tasks while sharing part of the base network. Li et al. (2019) with neural architecture search (NAS) find optimal network structures for each sequential task. RCL (Xu & Zhu, 2018) adaptively expands the network at each layer using reinforcement learning, whereas APD (Yoon et al., 2020) additively decomposes the parameters into shared and task specific parameters to minimize the increase in the network complexity. In contrast, our method avoids network growth or expensive NAS operations and performs sequential learning within a fixed network architecture.
|
| 24 |
+
|
| 25 |
+
Regularization-based methods: These methods attempt to overcome forgetting in fixed capacity model through structural regularization which penalizes major changes in the parameters that were important for the previous tasks. Elastic Weight Consolidation (EWC) (Kirkpatrick et al., 2017) computes such importance from diagonal of Fisher information matrix after training, whereas Zenke et al. (2017) compute them during training based on loss sensitivity with respect to the parameters. Additionally, Aljundi et al. (2018) compute importance from sensitivity of model outputs to the inputs. Other methods, such as PackNet (Mallya & Lazebnik, 2018) uses iterative pruning to fully restrict gradient updates on important weights via binary mask, whereas HAT (Serra et al., 2018) \` identifies important neurons by learning attention masks that control gradient propagation in the individual parameters. Saha et al. (2020) using a PCA based pruning on activations (Garg et al., 2020) partition the parametric space of the weights (filters) into core and residual (filter) spaces after learning each task. The past knowledge is preserved in the frozen core space, whereas the residual space is updated when learning the next task. In contrast to these methods, we do not ascribe importance to or restrict the gradients of any individual parameters or filters. Rather we put constraints on the ‘direction’ of gradient descent.
|
| 26 |
+
|
| 27 |
+
Memory-based methods: Methods under this class mitigate forgetting by either storing a subset of (raw) examples from the past tasks in the memory for rehearsal (Robins, 1995; Rebuffi et al., 2017; Lopez-Paz & Ranzato, 2017; Chaudhry et al., 2019a;b; Riemer et al., 2019) or synthesizing old data from generative models to perform pseudo-rehearsal (Shin et al., 2017). For instance,
|
| 28 |
+
|
| 29 |
+
Gradient Episodic Memory (GEM) (Lopez-Paz & Ranzato, 2017) avoids interference with previous task by projecting the new gradients in the feasible region outlined by previous task gradients calculated from the samples of episodic memory. Averaged-GEM (A-GEM) (Chaudhry et al., 2019a) simplified this optimization problem to projection in one direction estimated by randomly selected samples from the memory. Guo et al. (2020) propose a unified view of episodic memory-based CL methods, that include GEM and A-GEM and improves performance over these methods utilizing loss-balancing update rule. Additionally, Experience Replay (ER) (Chaudhry et al., 2019b) and Meta-Experience Replay (MER) (Riemer et al., 2019) mitigate forgetting in online CL setup by jointly training on the samples from new tasks and episodic memory. All these methods, however, rely on the access to old data which might not be possible when users have concern over data privacy. Like all the memory-based methods we also use a storage unit which we call GPM. However, we do not save any raw data in GPM, thus satisfy data privacy criterion.
|
| 30 |
+
|
| 31 |
+
Our method is closely related to recently proposed Orthogonal Gradient Descent (OGD) (Farajtabar et al., 2020) and Orthogonal Weight Modulation (OWM) (Zeng et al., 2018). OGD stores a set of gradient directions in the memory for each task and minimizes catastrophic forgetting by taking gradient steps in the orthogonal directions for new tasks. In contrast to OGD, we compute and store the bases of core gradient space from network representations (activations) which reduces the memory requirement by orders of magnitude. Moreover, OGD is shown to work under locality assumption for small learning rates which limits its scalability in learning longer task sequences with complex dataset. Since our method does not use gradient directions (like OGD) to describe the core gradient spaces, we do not need to obey such assumptions, thus can use higher learning rates. On the other hand, OWM reduces forgetting by modifying the weights of the network in the orthogonal to the input directions of the past tasks. This is achieved by multiplying new gradients with projector matrices. These matrices are computed from the stored past projectors and the inputs with recursive least square (RLS) method at each training step. However, such an iterative method not only slows down the training process but also shows limited scalability in end-to-end task learning with modern network architectures. Like OWM, we aim to encode new learning in the orthogonal to the old input directions. In contrast to iterative projector computation in OWM, we identify a low-dimensional subspace in the gradient space analyzing the learned representations with SVD in one-shot manner at the end of each task. We store the bases of these subspaces in GPM and learn new tasks in the orthogonal to these spaces to protect old knowledge. We quantitatively show that our method is memory efficient, fast and scalable to deeper networks for complex long sequence of tasks.
|
| 32 |
+
|
| 33 |
+
# 3 NOTATIONS AND BACKGROUND
|
| 34 |
+
|
| 35 |
+
In this section, we introduce the notations used throughout the paper and give a brief overview of SVD for matrix approximation. In section 4, we establish the relationship between input and gradient spaces. In section 5 we show the steps of our algorithm that leverage such relationship.
|
| 36 |
+
|
| 37 |
+
Continual Learning: We consider supervised learning setup where $T$ tasks are learned sequentially. Each task has a task descriptor, $\tau \in \{ 1 , 2 . . . . , T \}$ with a corresponding dataset, $\begin{array} { r l } { \mathbb { D } _ { \tau } } & { { } = } \end{array}$ $\{ ( \stackrel { \cdot } { \mathbfit { x } _ { i , \tau } } , \pmb { y } _ { i , \tau } ) _ { i = 1 } ^ { n _ { \tau } } \}$ having $n _ { \tau }$ example pairs. Let’s consider an $L$ layer neural network where at each layer network computes the following function for task $\tau$ :
|
| 38 |
+
|
| 39 |
+
$$
|
| 40 |
+
\begin{array} { r } { \pmb { x } _ { i , \tau } ^ { l + 1 } = \sigma ( f ( \pmb { W } _ { \tau } ^ { l } , \pmb { x } _ { i , \tau } ^ { l } ) ) . } \end{array}
|
| 41 |
+
$$
|
| 42 |
+
|
| 43 |
+
Here, $l = 1 , . . . L , \sigma ( . )$ is a non-linear function and $f ( . , . )$ is a linear function. We will use vector notation for input $( { \pmb x } _ { i , \tau } )$ in fully connected layers and matrix notation for input $( X _ { i , \tau } )$ in convolutional layers. At the first layer, $\pmb { x } _ { i , \tau } ^ { 1 } = \pmb { x } _ { i , \tau }$ represents the raw input data from task $\tau$ , whereas in the subsequent layers we define $\mathbf { \Delta } \mathbf { x } _ { i , \tau } ^ { l }$ as the representation of input $\mathbf { \boldsymbol { x } } _ { i , \tau }$ at layer $l$ . Set of parameters of the network is defined by, $\mathbb { W } _ { \tau } = \{ ( \mathbf { W } _ { \tau } ^ { l } ) _ { l = 1 } ^ { L } \}$ , where $\mathbb { W } _ { 0 }$ denotes set of parameters at initialization.
|
| 44 |
+
|
| 45 |
+
Matrix approximation with SVD: SVD can be used to factorize a rectangular matrix, ${ \textbf { \em A } } =$ $U \Sigma V ^ { T } \ \in \mathbb { R } ^ { m \times n }$ into the product of three matrices, where $U \in \mathbb { R } ^ { m \times m }$ and $V \in \mathbb { R } ^ { n \times n }$ are orthogonal, and $\pmb { \Sigma }$ contains the sorted singular values along its main diagonal (Deisenroth et al., 2020). If the rank of the matrix is $r$ , $( r \leq \operatorname* { m i n } ( m , n ) )$ ), $\pmb { A }$ can be expressed as $\begin{array} { r } { \pmb { A } = \sum _ { i = 1 } ^ { r } \sigma _ { i } \pmb { u } _ { i } \pmb { v } _ { i } ^ { T } } \end{array}$ where $\mathbf { } u _ { i } \in U$ and $\mathbf { } v _ { i } \in V$ are left and right singular vectors and $\sigma _ { i } \in d i a g ( \Sigma )$ are singular values. Also, $k$ -rank approximation to this matrix can be expressed as, $\begin{array} { r } { { \pmb { A } } _ { k } = \sum _ { i = 1 } ^ { k } \sigma _ { i } { \pmb { u } } _ { i } { \pmb { v } } _ { i } ^ { T } } \end{array}$ , where $k \leq r$ and its value can be chosen by the smallest $k$ that satisfies $| | A _ { k } | | _ { F } ^ { 2 } \geq \epsilon _ { t h } | | A | | _ { F } ^ { 2 }$ . Here, $| | . | | _ { F }$ is the Frobenius norm of the matrix and $\epsilon _ { t h }$ $0 < \epsilon _ { t h } \le 1 _ { \AA }$ ) is the threshold hyperparameter.
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
Figure 1: Illustration of convolution operation in matrix multiplication format during (a) Forward Pass and (b) Backward Pass.
|
| 49 |
+
|
| 50 |
+
# 4 INPUT AND GRADIENT SPACES
|
| 51 |
+
|
| 52 |
+
Our algorithm leverages the fact that stochastic gradient descent (SGD) updates lie in the span of input data points (Zhang et al., 2017). In the following subsections we will establish this relationship for both fully connected and convolutional layers. The analysis presented in this section is generally applicable to any layer of the network for any task, and hence we drop the task and layer identifiers.
|
| 53 |
+
|
| 54 |
+
# 4.1 FULLY CONNECTED LAYER
|
| 55 |
+
|
| 56 |
+
Let’s consider a single layer linear neural network in supervised learning setup where each (input, label) training data pair comes from a training dataset, $\mathbb { D }$ . Let, $\pmb { x } \in \mathbb { R } ^ { n }$ is the input vector, $\pmb { y } \in \mathbb { R } ^ { m }$ is the label vector in the dataset and $\pmb { W } \in \mathbb { R } ^ { \bar { m } \times n }$ are the parameters (weights) of the network. The network is trained by minimizing the following mean-squared error loss function
|
| 57 |
+
|
| 58 |
+
$$
|
| 59 |
+
L = \frac { 1 } { 2 } | | \boldsymbol { W } \boldsymbol { x } - \boldsymbol { y } | | _ { 2 } ^ { 2 } .
|
| 60 |
+
$$
|
| 61 |
+
|
| 62 |
+
We can express gradient of this loss with respect to weights as
|
| 63 |
+
|
| 64 |
+
$$
|
| 65 |
+
\nabla _ { W } L = ( W x - y ) \mathbf { { x } } ^ { T } = \delta \mathbf { { x } } ^ { T } ,
|
| 66 |
+
$$
|
| 67 |
+
|
| 68 |
+
where $\pmb { \delta } \in \mathbb { R } ^ { m }$ is the error vector. Thus, the gradient update will lie in the span of input $( { \pmb x } )$ , where elements in $\pmb { \delta }$ scale the magnitude of $_ { \textbf { \em x } }$ by different factors. Here, we have considered perexample loss (batch size of 1) for simplicity. However, this relation also holds for mini-batch setting (see appendix B.1). The input-gradient relation in equation 3 is generically applicable to any fully connected layer of a neural network where $_ { \textbf { \em x } }$ is the input to that layer and $\delta$ is the error coming from the next layer. Moreover, this equation also holds for network with non-linear units (e.g. ReLU) and cross-entropy losses except the calculation of $\delta$ will be different.
|
| 69 |
+
|
| 70 |
+
# 4.2 CONVOLUTIONAL LAYER
|
| 71 |
+
|
| 72 |
+
Filters in a convolutional (Conv) layer operate in a different way on the inputs than the weights in a fully connected (FC) layer. Let’s consider a Conv layer with the input tensor $\mathcal { X } \in \mathbb { R } ^ { C _ { i } \times \smile h _ { i } \times w _ { i } }$ and filters $\mathcal { W } \in \bar { \mathbb { R } } ^ { C _ { o } \times C _ { i } \times k \times k }$ . Their convolution $\langle \mathcal { X } , \mathcal { W } , \ast \rangle$ produces output feature map, $\mathcal { O } \in$ $\mathbb { R } ^ { C _ { o } \times h _ { o } \times w _ { o } }$ (Liu et al., 2018). Here, $C _ { i }$ $\left( C _ { o } \right)$ denotes the number of input (output) channels of the Conv layer, $h _ { i } , w _ { i } \ ( h _ { o } , w _ { o } )$ denote the height and width of the input (output) feature maps and $k$ is the kernel size of the filters. As shown in Figure 1(a), if $\mathcal { X }$ is reshaped into a $( h _ { o } \times w _ { o } ) \times ( C _ { i } \times k \times k )$ matrix, $\boldsymbol { X }$ and $\mathcal { W }$ is reshaped into a $( C _ { i } \times k \times k ) \times C _ { o }$ matrix, $W$ , then the convolution can be expressed as matrix multiplication between $\boldsymbol { X }$ and $W$ as $O { = } X W$ , where ${ \cal O } \in \mathbb { R } ^ { ( h _ { 0 } \times w _ { 0 } ) \times C _ { o } }$ . Each row of $\boldsymbol { X }$ contains an input patch vector, $\pmb { p } _ { j } \in \mathbb { R } ^ { ( C _ { i } \times k \times k ) \times 1 }$ , where $j = 1 , 2 . . . , n$ ${ ' n = h _ { o } * w _ { o } }$ ).
|
| 73 |
+
|
| 74 |
+
Formulation of convolution in terms of matrix multiplication provides an intuitive picture of the gradient computation during backpropagation. Similar to the FC layer case, in Conv layer, during backward pass an error matrix $\pmb { \Delta }$ of size $\left( h _ { 0 } \times w _ { 0 } \right) \times C _ { o }$ (same size as $o$ ) is obtained from the next layer. As shown in Figure 1(b), the gradient of loss with respect to filter weights is calculated by
|
| 75 |
+
|
| 76 |
+
$$
|
| 77 |
+
\nabla _ { W } L = X ^ { T } \Delta ,
|
| 78 |
+
$$
|
| 79 |
+
|
| 80 |
+
where, $\nabla _ { W } L$ is of shape $( C _ { i } \times k \times k ) \times C _ { o }$ (same size as $W$ ). Since, columns of $X ^ { T }$ are the input patch vectors $( p )$ , the gradient updates of the convolutional filters will lie in the space spanned by these patch vectors.
|
| 81 |
+
|
| 82 |
+
# 5 CONTINUAL LEARNING WITH GRADIENT PROJECTION MEMORY (GPM)
|
| 83 |
+
|
| 84 |
+
In this section, we describe our continual learning algorithm which leverages the relationship between gradient and input spaces to identify the core gradient spaces of the past tasks. We show how gradient descent orthogonal to these spaces enable us to learn continually without forgetting.
|
| 85 |
+
|
| 86 |
+
Learning Task 1: We learn the first task $\mathit { \check { \tau } } = 1$ ) using dataset, $\mathbb { D } _ { 1 }$ without imposing any constraint on parameter updates. At the end of Task 1, we obtain a learned set of parameters $\mathbb { W } _ { 1 }$ . To preserve the knowledge of the learned task, we impose constraints on the direction of gradient updates for the next tasks. To do so, we partition the entire gradient space into two (orthogonal) subspaces: Core Gradient Space (CGS) and Residual Gradient Space (RGS), such that gradient steps along CGS induce high interference on the learned tasks whereas gradient steps along RGS have minimum to no interference. We aim to find and store the bases of the CGS and take gradient steps orthogonal to the CGS for the next task. In our formulation, each layer has its own CGS.
|
| 87 |
+
|
| 88 |
+
To find the bases, after learning Task 1 , for each layer we construct a representation matrix, $[ \pmb { x } _ { 1 , 1 } ^ { l } , \pmb { x } _ { 2 , 1 } ^ { l } , . . . , \pmb { x } _ { n _ { s } , 1 } ^ { l } ]$ (for Conv layers $\pmb { R } _ { 1 } ^ { l } = [ ( \pmb { X } _ { 1 , 1 } ^ { \bar { l } } ) ^ { T } , ( \pmb { X } _ { 2 , 1 } ^ { l } ) ^ { T } , . . . , ( \hat { \pmb { X } } _ { n _ { s } , 1 } ^ { l } ) ^ { T } ]$ 1) concatenating $R _ { 1 } ^ { l } =$ $n _ { s }$ representations along the column obtained from forward pass of $n _ { s }$ random samples from the current training dataset through the network. Next, we perform SVD on $R _ { 1 } ^ { l } = U _ { 1 } ^ { l } \Sigma _ { 1 } ^ { l } ( \dot { V } _ { 1 } ^ { l } ) ^ { T }$ followed by its $k$ -rank approximation $( R _ { 1 } ^ { l } ) _ { k }$ according to the following criteria for the given threshold, $\epsilon _ { t h } ^ { l }$ :
|
| 89 |
+
|
| 90 |
+
$$
|
| 91 |
+
| | ( { \pmb R } _ { 1 } ^ { l } ) _ { k } | | _ { F } ^ { 2 } \geq \epsilon _ { t h } ^ { l } | | { \pmb R } _ { 1 } ^ { l } | | _ { F } ^ { 2 } .
|
| 92 |
+
$$
|
| 93 |
+
|
| 94 |
+
We define the space, $S ^ { l } = s p a n \{ \pmb { u } _ { 1 , 1 } ^ { l } , \pmb { u } _ { 2 , 1 } ^ { l } , . . . , \pmb { u } _ { k , 1 } ^ { l } \}$ , spanned by the first $k$ vectors in $U _ { 1 } ^ { l }$ as the space of significant representation for task 1 at layer $l$ since it contains all the directions with highest singular values in the representation. For the next task, we aim to take gradient steps in a way that the correlation between this task specific significant representation and the weights in each layer is preserved. Since, inputs span the space of gradient descent (section 4), the bases of $S ^ { l }$ will span a subspace in the gradient space which we define as the Core Gradient space (CGS). Thus gradient descent along CGS will cause maximum change in the input-weight correlation whereas gradient steps in the orthogonal directions to CGS (space of low representational significance) will induce very small to no interference to the old tasks. We define this subspace orthogonal to CGS as Residual Gradient space (RGS). We save the bases of the CGS in the memory, $\mathcal { M } = \{ ( M ^ { l } ) _ { l = 1 } ^ { L } \}$ , where $M ^ { l } = [ \pmb { u } _ { 1 , 1 } ^ { l } , \pmb { u } _ { 2 , 1 } ^ { l } , . . . , \pmb { u } _ { k , 1 } ^ { l } ]$ . We define this memory as Gradient Projection Memory (GPM).
|
| 95 |
+
|
| 96 |
+
Learning Task 2 to T: We learn task 2 with the examples from dataset $\mathbb { D } _ { 2 }$ only. Before taking gradient step, bases of the CGS are retrieved from GPM. New gradients $( \nabla _ { W _ { 2 } ^ { l } } L _ { 2 } )$ are first projected onto the CGS and then projected components are subtracted out from the new gradient so that remaining gradient components lie in the space orthogonal to CGS. Gradients are updated as
|
| 97 |
+
|
| 98 |
+
$$
|
| 99 |
+
\begin{array} { r l } { : } & { { } \nabla _ { W _ { 2 } ^ { l } } L _ { 2 } = \nabla _ { W _ { 2 } ^ { l } } L _ { 2 } - ( \nabla _ { W _ { 2 } ^ { l } } L _ { 2 } ) M ^ { l } ( M ^ { l } ) ^ { T } , } \end{array}
|
| 100 |
+
$$
|
| 101 |
+
|
| 102 |
+
At the end of the task 2 training, we update the GPM with new task-specific bases (of CGS). To obtain such bases, we construct $\mathbf { \bar { \mathbf { R } } } _ { 2 } ^ { l } = [ \mathbf { \dot { x } } _ { 1 , 2 } ^ { l } , \mathbf { x } _ { 2 , 2 } ^ { l } , . . . , \mathbf { x } _ { n _ { s } , 2 } ^ { l } ]$ using data from task 2 only. However, before performing SVD and subsequent $k$ -rank approximation, from $R _ { 2 } ^ { l }$ we eliminate the common directions (bases) that are already present in the GPM so that newly added bases are unique and orthogonal to the existing bases in the memory. To do so, we perform the following step :
|
| 103 |
+
|
| 104 |
+
$$
|
| 105 |
+
\hat { \pmb { R } } _ { 2 } ^ { l } = \pmb { R } _ { 2 } ^ { l } - \pmb { M } ^ { l } ( \pmb { M } ^ { l } ) ^ { T } ( \pmb { R } _ { 2 } ^ { l } ) = \pmb { R } _ { 2 } ^ { l } - \pmb { R } _ { 2 , P r o j } ^ { l } .
|
| 106 |
+
$$
|
| 107 |
+
|
| 108 |
+
Afterwards, SVD is performed on $\hat { \pmb { R } } _ { 2 } ^ { l } ( = \hat { U } _ { 2 } ^ { l } \hat { \pmb { \Sigma } } _ { 2 } ^ { l } ( \hat { V } _ { 2 } ^ { l } ) ^ { T } )$ and $k$ new orthogonal bases are chosen for minimum value of $k$ satisfying the following criteria for the given threshold, $\epsilon _ { t h } ^ { l }$ :
|
| 109 |
+
|
| 110 |
+
$$
|
| 111 |
+
| | R _ { 2 , p r o j } ^ { l } | | _ { F } ^ { 2 } + | | ( \hat { R } _ { 2 } ^ { l } ) _ { k } | | _ { F } ^ { 2 } \geq \epsilon _ { t h } ^ { l } | | R _ { 2 } ^ { l } | | _ { F } ^ { 2 } .
|
| 112 |
+
$$
|
| 113 |
+
|
| 114 |
+
GPM is updated by adding new bases as $M ^ { l } = [ M ^ { l } , \hat { \boldsymbol { u } } _ { 1 , 2 } ^ { l } , . . . , \hat { \boldsymbol { u } } _ { k , 2 } ^ { l } ]$ . Thus after learning each new task, CGS grows and RGS becomes smaller, where maximum size of $M ^ { l }$ (hence the dimension of the gradient bases) is fixed by the choice of initial network architecture. Once the GPM update is complete we move on to the next task and repeat the same procedure that we followed for task 2. The pseudo-code of the algorithm is given in Algorithm 1 in the appendix.
|
| 115 |
+
|
| 116 |
+
# 6 EXPERIMENTAL SETUP
|
| 117 |
+
|
| 118 |
+
Datasets: We evaluate our continual learning algorithm on Permuted MNIST (PMNIST) (Lecun et al., 1998), 10-Split CIFAR-100 (Krizhevsky, 2009), 20-Spilt miniImageNet (Vinyals et al., 2016) and sequence of 5-Datasets (Ebrahimi et al., 2020b). The PMNIST dataset is a variant of MNIST dataset where each task is considered as a random permutation of the original MNIST pixels. For PMNIST, we create 10 sequential tasks using different permutations where each task has 10 classes (Ebrahimi et al., 2020a). The 10-Split CIFAR-100 is constructed by splitting 100 classes of CIFAR-100 into 10 tasks with 10 classes per task. Whereas, 20-Spilt miniImageNet, used in (Chaudhry et al., 2019a), is constructed by splitting 100 classes of miniImageNet into 20 sequential tasks where each task has 5 classes. Finally, we use a sequence of 5-Datasets including CIFAR10, MNIST, SVHN (Netzer et al., 2011), notMNIST (Bulatov, 2011) and Fashion MNIST (Xiao et al., 2017), where classification on each dataset is considered as a task. In our experiments we do not use any data augmentation. The dataset statistics are given in Table 4 & 5 in the appendix.
|
| 119 |
+
|
| 120 |
+
Network Architecture: We use fully-connected network with two hidden layer of 100 units each for PMNIST following Lopez-Paz & Ranzato (2017). For experiments with split CIFAR-100 we use a 5-layer AlexNet similar to Serra et al. (2018). For split miniImageNet and 5-Datasets, similar \` to Chaudhry et al. (2019b), we use a reduced ResNet18 architecture. No bias units are used and batch normalization parameters are learned for the first task and shared with all the other tasks (following Mallya & Lazebnik (2018)). Details on architectures are given in the appendix section C.2. For permuted MNIST, we evaluate and compare our algorithm in ‘single-head’ setting (Hsu et al., 2018; Farquhar & Gal, 2018) where all tasks share the final classifier layer and inference is performed without task hint. For all other experiments, we evaluate our algorithm in ‘muti-head’ setting, where each task has a separate classifier on which no gradient constraint is imposed during learning.
|
| 121 |
+
|
| 122 |
+
Baselines: We compare our method with state-of-the art approaches from both memory based and regularization based methods that consider sequential task learning in fixed network architecture. From memory based approach, we compare with Experience Replay with reservoir sampling (ER Res) (Chaudhry et al., 2019b), Gradient Episodic Memory (GEM) (Lopez-Paz & Ranzato, 2017), Averaged GEM (A-GEM) (Chaudhry et al., 2019a), Orthogonal Gradient Descent (OGD) (Farajtabar et al., 2020) and Orthogonal Weight Modulation (OWM) (Zeng et al., 2018). Moreover, we compare with sate-of-the-art HAT (Serra et al., 2018) baseline and Elastic Weight \` Consolidation (EWC) (Kirkpatrick et al., 2017) from regularization based methods. Additionally, we add ‘multitask’ baseline where all the tasks are learned jointly using the entire dataset at once in a single network. Multitask is not a continual learning strategy but will serve as upper bound on average accuracy on all tasks. Details on the implementation along with the hyperparameters considered for each of these baselines are provided in section C.4 and Table 6 in the appendix.
|
| 123 |
+
|
| 124 |
+
Training Details: We train all the models with plain stochastic gradient descent (SGD). For each task in PMNIST and split miniImageNet we train the network for 5 and 10 epochs respectively with batch size of 10. In Split CIFAR-100 and 5-Datasets experiments, we train each task for maximum of 200 and 100 epochs respectively with the early termination strategy based on the validation loss as proposed in Serra et al. (2018). For both datasets, batch size is set to 64. For GEM, A-GEM \` and ER Res the episodic memory size is chosen to be approximately the same size as the maximum GPM size (GPM Max). Calculation of GPM size is given in Table 7 in the appendix. Moreover, selection of the threshold values $( \epsilon _ { t h } )$ in our method is discussed in section C.5 in the appendix.
|
| 125 |
+
|
| 126 |
+
Performance Metrics: To evaluate the classification performance, we use the ACC metric, which is the average test classification accuracy of all tasks. To measure the forgetting we report backward transfer, BWT which indicates the influence of new learning on the past knowledge. For instance, negative BWT indicates (catastrophic) forgetting. Formally, ACC and BWT are defined as:
|
| 127 |
+
|
| 128 |
+
$$
|
| 129 |
+
\mathsf { A C C } = \frac { 1 } { T } \sum _ { i = 1 } ^ { T } R _ { T , i } , \quad \mathsf { B W T } = \frac { 1 } { T - 1 } \sum _ { i = 1 } ^ { T - 1 } R _ { T , i } - R _ { i , i } .
|
| 130 |
+
$$
|
| 131 |
+
|
| 132 |
+
Here, $T$ is the total number of sequential tasks and $R _ { T , i }$ is the accuracy of the model on $i ^ { t h }$ task after learning the $T ^ { t h }$ task sequentially (Lopez-Paz & Ranzato, 2017).
|
| 133 |
+
|
| 134 |
+
# 7 RESULTS AND DISCUSSIONS
|
| 135 |
+
|
| 136 |
+
Single-head inference with PMNIST: First, we evaluate our algorithm in single-head setup for 10 sequential PMNIST tasks. In this setup task hint is not necessary. As HAT cannot perform inference without task hint, it is not included in the comparison. Since network size is very small (0.1M parameters) with $8 7 \%$ parameters in the first layer, we choose threshold value $( \epsilon _ { t h } )$ of 0.95 for that layer and 0.99 for the other layers to ensure better learnability. From the results, shown in Table 1(a), we observe that our method (GPM) achieves best average accuracy $( 9 3 . 9 1 \pm 0 . 1 6 \% )$ . In addition, we achieve least amount of forgetting, except OWM, which essentially trades off accuracy to minimize forgetting. Figure 2(a) compares the memory utilization of all the memory-based approaches. While OWM, GEM, A-GEM and ER Res use memory of size of GPM Max, we obtain better performance by using only $6 9 \%$ of the GPM Max. Moreover, compared to OGD, we use about 400 times lower memory and achieve $\sim 1 0 \%$ better accuracy. In Figure 2(b), we compare the per epoch training time of different memory based methods and found our method to be the fastest primarily due to the precomputation of the reference gradient bases (of CGS). Additionally, in single-epoch setting (Lopez-Paz & Ranzato, 2017), as shown in Table 8 in the appendix, we obtain best average accuracy $( 9 1 . 7 4 \pm 0 . 1 5 \%$ ), which demonstrates the potential for our algorithm in online CL setup.
|
| 137 |
+
|
| 138 |
+

|
| 139 |
+
Figure 2: (a) Memory utilization and (b) per epoch training time for PMNIST tasks for different methods. Memory utilization for different approaches for (c) CIFAR-100, (d) miniImageNet and (e) 5-Datasets tasks. For memory, size of GPM Max and for time, method with highest complexity is used as references (value of 1). All the other methods are reported relative to these references.
|
| 140 |
+
|
| 141 |
+
Table 1: Continual learning on different datasets. Methods that do not adhere to CL setup is indicated by $( ^ { * } )$ . All the results are (re) produced by us and averaged over 5 runs. Standard deviations are reported in Table 8 and 9 in the appendix.
|
| 142 |
+
|
| 143 |
+
<table><tr><td colspan="3">(a)</td></tr><tr><td rowspan="2">Methods</td><td>PMNIST</td><td></td></tr><tr><td>ACC (%)</td><td>BWT</td></tr><tr><td>OGD</td><td>82.56</td><td>- 0.14</td></tr><tr><td>OWM</td><td>90.71</td><td>- 0.01</td></tr><tr><td>GEM</td><td>83.38</td><td>- 0.15</td></tr><tr><td>A-GEM</td><td>83.56</td><td>- 0.14</td></tr><tr><td>ER_Res</td><td>87.24</td><td>- 0.11</td></tr><tr><td>EWC</td><td>89.97</td><td>-0.04</td></tr><tr><td>GPM (ours)</td><td>93.91</td><td>-0.03</td></tr><tr><td>Multitask*</td><td>96.70</td><td>-</td></tr></table>
|
| 144 |
+
|
| 145 |
+
<table><tr><td colspan="7">(b)</td></tr><tr><td></td><td colspan="2">CIFAR-100</td><td colspan="2">miniImageNet</td><td colspan="2">5-Datasets</td></tr><tr><td>Methods</td><td>ACC (%)</td><td>BWT</td><td>ACC (%)</td><td>BWT</td><td>ACC (%)</td><td>BWT</td></tr><tr><td>OWM</td><td>50.94</td><td>- 0.30</td><td>=</td><td>=</td><td>=</td><td>=</td></tr><tr><td>EWC</td><td>68.80</td><td>-0.02</td><td>52.01</td><td>-0.12</td><td>88.64</td><td>-0.04</td></tr><tr><td>HAT</td><td>72.06</td><td>- 0.00</td><td>59.78</td><td>-0.03</td><td>91.32</td><td>-0.01</td></tr><tr><td>A-GEM</td><td>63.98</td><td>- 0.15</td><td>57.24</td><td>-0.12</td><td>84.04</td><td>-0.12</td></tr><tr><td>ER_Res</td><td>71.73</td><td>- 0.06</td><td>58.94</td><td>-0.07</td><td>88.31</td><td>- 0.04</td></tr><tr><td>GPM (ours)</td><td>72.48</td><td>-0.00</td><td>60.41</td><td>-0.00</td><td>91.22</td><td>- 0.01</td></tr><tr><td>Multitask*</td><td>79.58</td><td>-</td><td>69.46</td><td>-</td><td>91.54</td><td>-</td></tr></table>
|
| 146 |
+
|
| 147 |
+
Split CIFAR-100: Next, we switch to multi-head setup which enables us to compare with strong baselines such as HAT. For ten split CIFAR-100 tasks, as shown in Table 1(b), we outperform all the memory based approaches while using $4 5 \%$ less memory (Figure 2(c)). We also outperform EWC and our accuracy is marginally better than HAT while achieving zero forgetting. Also, we obtain $\sim 2 0 \%$ better accuracy than OWM, which have high forgetting $( \mathbf { B } \mathbf { W } \mathbf { T } { = } { - } 0 . 3 0 )$ thus demonstrating its limited scalability to convolutional architectures.
|
| 148 |
+
|
| 149 |
+
Split miniImageNet: With this experiment, we test the scalability of our algorithm to deeper network (ResNet18) for long task sequence from miniImageNet dataset. The average accuracies for different methods after learning 20 sequential tasks are given in Table 1(b). Again, in this case we outperform A-GEM, ER Res and EWC using $7 6 \%$ of the GPM Max (Figure 2(d)). Also, we achieve marginally better accuracy than HAT, however unlike HAT (and other methods) we completely avoid forgetting $( \mathbf { B } \mathbf { W } \mathbf { T } { = } 0 . 0 0 ) ,$ . Moreover, compared other methods sequential learning in our method is more stable, which means accuracy of the past tasks have minimum to no degradation over the course of learning (shown for task 1 accuracy in Figure 4 in the appendix).
|
| 150 |
+
|
| 151 |
+
5-Datasets: Next, we validate our approach on learning across diverse datasets, where classification on each dataset is treated as one task. Even in this challenging setting, as shown in in Table 1(b), we achieve better accuracy $( 9 1 . 2 2 \pm 0 . 2 0 \% )$ ) then A-GEM, ER Res and EWC utilizing $7 8 \%$ of the GPM Max (Figure 2(e)). Though, HAT performs marginally better than our method, both HAT and we achieve the lowest BWT (-0.01). In this experiment, we have used tasks that are less related to each other. After learning 5 such tasks $78 \%$ of the gradient space is already constrained. Which implies, if the tasks are less or non-similar, GPM will get populated faster and reach to its maximum capacity after which no new learning will be possible. Since, we use a fixed capacity network and the size of GPM is determined by the network architecture, the ability of learning sequences of hundreds of such tasks with our method will be limited by the chosen network capacity.
|
| 152 |
+
|
| 153 |
+
Table 2: Total wall-clock training time measured on a single GPU after learning all the tasks. (a) (b)
|
| 154 |
+
|
| 155 |
+
<table><tr><td rowspan=1 colspan=1>(a)</td></tr><tr><td rowspan=1 colspan=1>Training Time [s]Methods PMNIST</td></tr><tr><td rowspan=1 colspan=1>OGD 1658</td></tr><tr><td rowspan=1 colspan=1>OWM 396</td></tr><tr><td rowspan=1 colspan=1>GEM 1639</td></tr><tr><td rowspan=1 colspan=1>A-GEM 445</td></tr><tr><td rowspan=1 colspan=1>ER_Res 259</td></tr><tr><td rowspan=1 colspan=1>EWC 645</td></tr><tr><td rowspan=1 colspan=1>GPM (ours) 245</td></tr></table>
|
| 156 |
+
|
| 157 |
+
<table><tr><td></td><td colspan="3">Training Time [s]</td></tr><tr><td>Methods</td><td>CIFAR-100</td><td>miniImageNet</td><td>5-Datasets</td></tr><tr><td>OWM</td><td>1856</td><td>1</td><td>1</td></tr><tr><td>EWC</td><td>1352</td><td>4138</td><td>7613</td></tr><tr><td>HAT</td><td>1248</td><td>3077</td><td>7246</td></tr><tr><td>A-GEM</td><td>2678</td><td>6069</td><td>12077</td></tr><tr><td>ER_Res</td><td>1147</td><td>2775</td><td>7015</td></tr><tr><td>GPM (ours)</td><td>770</td><td>3387</td><td>5008</td></tr></table>
|
| 158 |
+
|
| 159 |
+
Table 3: Continual learning of 20-task from CIFAR-100 Superclass dataset. (†) denotes the result reported from APD. $( ^ { * } )$ indicates the methods that do not adhere to CL setup. Single-task learning (STL), where a separate network in trained for each task, serves as an upper bound on accuracy.
|
| 160 |
+
|
| 161 |
+
<table><tr><td></td><td colspan="6">Methods</td></tr><tr><td>Metric</td><td>STL+*</td><td>PGNt</td><td>DEN†</td><td>RCL†</td><td>APDt</td><td>GPM (ours)</td></tr><tr><td>ACC (%)</td><td>61.00</td><td>50.76</td><td>51.10</td><td>51.99</td><td>56.81</td><td>57.72</td></tr><tr><td>Capacity (%)</td><td>2000</td><td>271</td><td>191</td><td>184</td><td>130</td><td>100</td></tr></table>
|
| 162 |
+
|
| 163 |
+
Training Time. Table 2 shows the total training time for all the sequential tasks for different algorithms. This includes time spent for memory management for the memory-based methods, fisher importance calculation for EWC and learning activation masks for HAT. Details of time measurement are given in appendix section C.6. For PMNIST, CIFAR-100, and 5-dataset tasks our algorithm trains faster than all the other baselines while spending only $0 . 2 \%$ , $3 \%$ and $6 \%$ of its total training time in GPM update (using SVD) respectively. Since each miniImageNet tasks are trained for only 10 epochs, our method have relatively higher overhead $3 0 \%$ of the total time) due to GPM update, thus runs a bit slower than the fastest ER Res. Overall, our formulation uses GPM bases and projection matrices of reasonable dimensions (see appendix section C.8); precomputation of which at the start of each task leads to fast per-epoch training. This gain in time essentially compensates for the extra time required for the GPM update, which is done only once per task, enabling fast training.
|
| 164 |
+
|
| 165 |
+
Comparison with Expansion-based methods. To compare our method with the state-of-the-art expansion based methods we perform experiment with 20-task CIFAR-100 Superclass dataset (Yoon et al., 2020). In this experiment, each task contains 5 different but semantically related classes from CIFAR-100 dataset. Similar to APD, here we use the LeNet-5 architecture. Details of architecture and training setup are given in appendix section C.3. Results are shown in Table 3 where ACC represents average accuracy over 5 different task sequences (used in APD) and Capacity denotes percentage of network capacity used with respect to the original network. We outperform all the CL methods achieving best average accuracy $( 5 7 . 7 2 \pm 0 . 3 7 \% )$ with BWT of -0.01 using the smallest network. For instance, we outperform RCL and APD utilizing $8 4 \%$ and $3 0 \%$ fewer network parameters respectively, which shows that our method induces more sharing between tasks.
|
| 166 |
+
|
| 167 |
+
Overall, we outperform the memory-based methods with less memory utilization, achieve better accuracy than expansion-based methods using smaller network, and obtain better or on-par performance compared to HAT in the given experimental setups. However, in the class-incremental learning setup (Rebuffi et al., 2017), method (Kamra et al., 2017) that uses data replay achieves better performance than GPM (see experiment in appendix section D.3). In this setup, we believe a subset of old data replay either from storage or via generation is inevitable for attaining better performance with minimal forgetting (Rajasegaran et al., 2019). In that quest, a hybrid approach such as combining GPM with small data replay would be an interesting direction for future exploration.
|
| 168 |
+
|
| 169 |
+

|
| 170 |
+
Figure 3: Histograms of interference activations as a function of threshold, $( \epsilon _ { t h } )$ at (a) Conv layer 2 (b) FC layer 2 for split CIFAR-100 tasks. (c) Impact of $\epsilon _ { t h }$ on ACC $( \% )$ and $B W \mathrm { T } ( \% )$ . With increasing value of $\epsilon _ { t h }$ , spread of interference reduces, which improves accuracy and reduces forgetting.
|
| 171 |
+
|
| 172 |
+
Controlling Forgetting: Finally, we discuss the factors that implicitly or explicitly control the amount of forgetting in our algorithm. As discussed in section 5, we propose to minimize interference by taking gradient steps orthogonal to the CGS, where CGS bases are computed such that space of significant representations of the past tasks can be well approximated by these bases. The degree of this approximation is controlled by the threshold hyperparameter, $\epsilon _ { t h }$ (through equation 5, 9). For instance, a low value of $\epsilon _ { t h }$ (closer to 0) would allow the optimizer to change the weights along the directions where past data has higher representational significance, thereby significantly altering the past input-weight correlation inducing (catastrophic) interference. On the other hand, a high value of $\epsilon _ { t h }$ (closer to 1) would preserve such correlation, however learnability of the new task might suffer due to high volume of constraints in the gradient space. Therefore, in our continual learning algorithm, $\epsilon _ { t h }$ mediates the stability-plasticity dilemma. To show this analytically, let’s consider a network after learning $T$ sequential tasks with weights of the network at any layer, $l$ expressed as :
|
| 173 |
+
|
| 174 |
+
$$
|
| 175 |
+
\mathbf { \Delta } W _ { T } ^ { l } = W _ { 1 } ^ { l } + \sum _ { i = 1 } ^ { T - 1 } \Delta W _ { i i + 1 } ^ { l } = W _ { 1 } ^ { l } + \Delta W _ { 1 T } ^ { l } .
|
| 176 |
+
$$
|
| 177 |
+
|
| 178 |
+
Here, $\pmb { W } _ { 1 } ^ { l }$ is the weights after task 1 and $\Delta W _ { 1 T } ^ { l }$ is the change of weights from task 1 to $\mathrm { T }$ . Weight update with our method ensures that $\Delta { W _ { 1 T } ^ { l } }$ lie in the orthogonal space of the data (representations) of task 1. Linear operation at layer $l$ with data from task 1 $( { \pmb x } _ { 1 } )$ would produce: $\pmb { W } _ { T } ^ { l } \pmb { x } _ { 1 } ^ { l } = \pmb { W } _ { 1 } ^ { l } \pmb { x } _ { 1 } ^ { l } + \Delta \pmb { W } _ { 1 T } ^ { l } \pmb { x } _ { 1 } ^ { l }$ . If $\Delta { W } _ { 1 T } ^ { l } \pmb { x } _ { 1 } ^ { l ^ { \prime } } = 0$ , then the output of the network for task 1 data after learning task $T$ will be the same as the output after learning task 1 (i.e. $\pmb { W } _ { T } ^ { l } \pmb { x } _ { 1 } ^ { l } = \pmb { W } _ { 1 } ^ { l } \pmb { x } _ { 1 } ^ { l } )$ , that means no interference for task 1. We define $\Delta W _ { 1 T } ^ { l } \pmb { x } _ { 1 } ^ { l }$ as the interference activation for task 1 at layer $l$ (for any task, $\tau < T$ : $\Delta W _ { \tau T } ^ { l } \mathbf { x } _ { \tau } ^ { l } )$ . As discussed above, degree of such interference is dictated by $\epsilon _ { t h }$ . Figure 3(a)-(b) (and Figure 5 in appendix) show histograms (distributions) of interference activations at each layer of the network for split CIFAR-100 experiment. For lower value of $\epsilon _ { t h }$ , these distributions have higher variance (spread) implying high interference, whereas with increasing value of $\epsilon _ { t h }$ , the variance reduces around the (zero) mean value. As a direct consequence, as shown in Figure 3(c), backward transfer reduces for increasing $\epsilon _ { t h }$ with improvement in accuracy.
|
| 179 |
+
|
| 180 |
+
# 8 CONCLUSION
|
| 181 |
+
|
| 182 |
+
In this paper we propose a novel continual learning algorithm that finds important gradient subspaces for the past tasks and minimizes catastrophic forgetting by taking gradient steps orthogonal to these subspaces when learning a new task. We show how to analyse the network representations to obtain minimum number of bases of these subspaces by which past information is preserved and learnability for the new tasks is ensured. Evaluation on diverse image classification tasks with different network architectures and comparisons with state-of-the-art algorithms show the effectiveness of our approach in achieving high classification performance while mitigating forgetting. We also show our algorithm is fast, makes efficient use of memory and is capable of learning long sequence of tasks in deeper networks preserving data privacy.
|
| 183 |
+
|
| 184 |
+
# ACKNOWLEDGMENTS
|
| 185 |
+
|
| 186 |
+
This work was supported in part by the National Science Foundation, Vannevar Bush Faculty Fellowship, Army Research Office, MURI, and by Center for Brain Inspired Computing (C-BRIC), one of six centers in JUMP, a Semiconductor Research Corporation program sponsored by DARPA.
|
| 187 |
+
|
| 188 |
+
# REFERENCES
|
| 189 |
+
|
| 190 |
+
Rahaf Aljundi, Francesca Babiloni, Mohamed Elhoseiny, Marcus Rohrbach, and Tinne Tuytelaars. Memory aware synapses: Learning what (not) to forget. In The European Conference on Computer Vision (ECCV), pp. 139–154, 2018.
|
| 191 |
+
|
| 192 |
+
Mehdi Abbana Bennani, Thang Doan, and Masashi Sugiyama. Generalisation guarantees for continual learning with orthogonal gradient descent. ArXiv, abs/2006.11942, 2020.
|
| 193 |
+
|
| 194 |
+
Yaroslav Bulatov. Notmnist dataset. Google (Books/OCR), Tech. Rep.[Online], 2011. URL http: //yaroslavvb.blogspot.it/2011/09/notmnist-dataset.html.
|
| 195 |
+
|
| 196 |
+
Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with A-GEM. In International Conference on Learning Representations, 2019a.
|
| 197 |
+
|
| 198 |
+
Arslan Chaudhry, Marcus Rohrbach, Mohamed Elhoseiny, Thalaiyasingam Ajanthan, Puneet K. Dokania, Philip H. S. Torr, and Marc’Aurelio Ranzato. Continual learning with tiny episodic memories. ArXiv, abs/1902.10486, 2019b.
|
| 199 |
+
|
| 200 |
+
Marc Peter Deisenroth, A. Aldo Faisal, and Cheng Soon Ong. Mathematics for Machine Learning. Cambridge University Press, 2020.
|
| 201 |
+
|
| 202 |
+
Sayna Ebrahimi, Mohamed Elhoseiny, Trevor Darrell, and Marcus Rohrbach. Uncertainty-guided continual learning with bayesian neural networks. In International Conference on Learning Representations, 2020a.
|
| 203 |
+
|
| 204 |
+
Sayna Ebrahimi, Franziska Meier, Roberto Calandra, Trevor Darrell, and Marcus Rohrbach. Adversarial continual learning. In The European Conference on Computer Vision (ECCV), 2020b.
|
| 205 |
+
|
| 206 |
+
Mehrdad Farajtabar, Navid Azizan, Alex Mott, and Ang Li. Orthogonal gradient descent for continual learning. ArXiv, abs/1910.07104, 2020.
|
| 207 |
+
|
| 208 |
+
Sebastian Farquhar and Yarin Gal. Towards robust evaluations of continual learning. ArXiv, abs/1805.09733, 2018.
|
| 209 |
+
|
| 210 |
+
Isha Garg, Priyadarshini Panda, and Kaushik Roy. A low effort approach to structured cnn design using pca. IEEE Access, 8:1347–1360, 2020.
|
| 211 |
+
|
| 212 |
+
Ian Goodfellow, Yoshua Bengio, Aaron Courville, and Yoshua Bengio. Deep learning, volume 1. MIT Press, 2016.
|
| 213 |
+
|
| 214 |
+
Yunhui Guo, Mingrui Liu, Tianbao Yang, and Tajana Rosing. Improved schemes for episodic memory-based lifelong learning. In Advances in Neural Information Processing Systems 33, 2020.
|
| 215 |
+
|
| 216 |
+
Yen-Chang Hsu, Yen-Cheng Liu, Anita Ramasamy, and Zsolt Kira. Re-evaluating continual learning scenarios: A categorization and case for strong baselines. In NeurIPS Continual learning Workshop, 2018. URL https://arxiv.org/abs/1810.12488.
|
| 217 |
+
|
| 218 |
+
Nitin Kamra, Umang Gupta, and Yan Liu. Deep generative dual memory network for continual learning. ArXiv, abs/1710.10368, 2017.
|
| 219 |
+
|
| 220 |
+
James Kirkpatrick, Razvan Pascanu, Neil C. Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A. Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, Demis Hassabis, Claudia Clopath, Dharshan Kumaran, and Raia Hadsell. Overcoming catastrophic forgetting in neural networks. Proceedings of the National Academy of Sciences, 114:3521 – 3526, 2017.
|
| 221 |
+
|
| 222 |
+
Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
|
| 223 |
+
|
| 224 |
+
Matthias De Lange, Rahaf Aljundi, Marc Masana, Sarah Parisot, Xu Jia, Ales Leonardis, Gregory Slabaugh, and Tinne Tuytelaars. A continual learning survey: Defying forgetting in classification tasks. IEEE Transactions on Pattern Analysis and Machine Intelligence, pp. 1–1, 2021.
|
| 225 |
+
|
| 226 |
+
Yann Lecun, Leon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to ´ document recognition. In Proceedings of the IEEE, pp. 2278–2324, 1998.
|
| 227 |
+
|
| 228 |
+
Xilai Li, Yingbo Zhou, Tianfu Wu, Richard Socher, and Caiming Xiong. Learn to grow: A continual structure learning framework for overcoming catastrophic forgetting. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 3925–3934. PMLR, 09–15 Jun 2019.
|
| 229 |
+
|
| 230 |
+
Zhenhua Liu, Jizheng Xu, Xiulian Peng, and Ruiqin Xiong. Frequency-domain dynamic pruning for convolutional neural networks. In Advances in Neural Information Processing Systems 31, pp. 1043–1053. 2018.
|
| 231 |
+
|
| 232 |
+
David Lopez-Paz and Marc' Aurelio Ranzato. Gradient episodic memory for continual learning. In Advances in Neural Information Processing Systems, volume 30, 2017.
|
| 233 |
+
|
| 234 |
+
Arun Mallya and Svetlana Lazebnik. Packnet: Adding multiple tasks to a single network by iterative pruning. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7765– 7773, 2018.
|
| 235 |
+
|
| 236 |
+
Michael Mccloskey and Neil J. Cohen. Catastrophic interference in connectionist networks: The sequential learning problem. The Psychology of Learning and Motivation, 24:104–169, 1989.
|
| 237 |
+
|
| 238 |
+
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y. Ng. Reading digits in natural images with unsupervised feature learning. 2011.
|
| 239 |
+
|
| 240 |
+
Jathushan Rajasegaran, Munawar Hayat, Salman H Khan, Fahad Shahbaz Khan, and Ling Shao. Random path selection for continual learning. In Advances in Neural Information Processing Systems, volume 32, pp. 12669–12679, 2019.
|
| 241 |
+
|
| 242 |
+
Roger Ratcliff. Connectionist models of recognition memory: constraints imposed by learning and forgetting functions. Psychological review, 97 2:285–308, 1990.
|
| 243 |
+
|
| 244 |
+
Sylvestre-Alvise Rebuffi, Alexander Kolesnikov, Georg Sperl, and Christoph H. Lampert. iCaRL: Incremental classifier and representation learning. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5533–5542, 2017.
|
| 245 |
+
|
| 246 |
+
Matthew Riemer, Ignacio Cases, Robert Ajemian, Miao Liu, Irina Rish, Yuhai Tu, and Gerald Tesauro. Learning to learn without forgetting by maximizing transfer and minimizing interference. In International Conference on Learning Representations, 2019.
|
| 247 |
+
|
| 248 |
+
Mark B. Ring. Child: A first step towards continual learning. In Learning to Learn, 1998.
|
| 249 |
+
|
| 250 |
+
Anthony V. Robins. Catastrophic forgetting, rehearsal and pseudorehearsal. Connect. Sci., 7:123– 146, 1995.
|
| 251 |
+
|
| 252 |
+
Andrei A. Rusu, Neil C. Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Koray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks. ArXiv, abs/1606.04671, 2016.
|
| 253 |
+
|
| 254 |
+
Gobinda Saha, Isha Garg, Aayush Ankit, and Kaushik Roy. Space: Structured compression and sharing of representational space for continual learning. ArXiv, abs/2001.08650, 2020.
|
| 255 |
+
|
| 256 |
+
Syed Shakib Sarwar, Aayush Ankit, and Kaushik Roy. Incremental learning in deep convolutional neural networks using partial network sharing. IEEE Access, 8:4615–4628, 2020.
|
| 257 |
+
|
| 258 |
+
Joan Serra, D \` ´ıdac Sur´ıs, Marius Miron, and Alexandros Karatzoglou. Overcoming catastrophic forgetting with hard attention to the task. In Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pp. 4548–4557. PMLR, 10–15 Jul 2018.
|
| 259 |
+
|
| 260 |
+
Hanul Shin, Jung Kwon Lee, Jaehong Kim, and Jiwon Kim. Continual learning with deep generative replay. In Advances in Neural Information Processing Systems, volume 30, 2017.
|
| 261 |
+
|
| 262 |
+
Sebastian Thrun and Tom M. Mitchell. Lifelong robot learning. Robotics Auton. Syst., 15:25–46, 1995.
|
| 263 |
+
|
| 264 |
+
Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Advances in Neural Information Processing Systems, volume 29, 2016.
|
| 265 |
+
|
| 266 |
+
Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms. ArXiv, abs/1708.07747, 2017.
|
| 267 |
+
|
| 268 |
+
Ju Xu and Zhanxing Zhu. Reinforced continual learning. In Advances in Neural Information Processing Systems, volume 31, pp. 899–908, 2018.
|
| 269 |
+
|
| 270 |
+
Jaehong Yoon, Eunho Yang, Jeongtae Lee, and Sung Ju Hwang. Lifelong learning with dynamically expandable networks. In 6th International Conference on Learning Representations, 2018.
|
| 271 |
+
|
| 272 |
+
Jaehong Yoon, Saehoon Kim, Eunho Yang, and Sung Ju Hwang. Scalable and order-robust continual learning with additive parameter decomposition. In International Conference on Learning Representations, 2020.
|
| 273 |
+
|
| 274 |
+
Guanxiong Zeng, Yang Chen, Bo Cui, and Shan Yu. Continuous learning of context-dependent processing in neural networks. ArXiv, abs/1810.01256, 2018.
|
| 275 |
+
|
| 276 |
+
Friedemann Zenke, Ben Poole, and Surya Ganguli. Continual learning through synaptic intelligence. In Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 3987–3995. PMLR, 06–11 Aug 2017.
|
| 277 |
+
|
| 278 |
+
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In International Conference on Learning Representations, 2017.
|
| 279 |
+
|
| 280 |
+
A APPENDIX B ALGORITHM
|
| 281 |
+
|
| 282 |
+
B.1 INPUT AND GRADIENT SPACES (CONT.)
|
| 283 |
+
|
| 284 |
+
Since, the batch loss is the summation of the losses due to individual examples, the total batch loss for $n$ samples can be expressed as
|
| 285 |
+
|
| 286 |
+
$$
|
| 287 |
+
L _ { b a t c h } = \sum _ { i = 1 } ^ { n } L _ { i } = \sum _ { i = 1 } ^ { n } \frac { 1 } { 2 } | | W \pmb { x } _ { i } - \pmb { y } _ { i } | | _ { 2 } ^ { 2 } .
|
| 288 |
+
$$
|
| 289 |
+
|
| 290 |
+
The gradient of this loss with respect to weights can be expressed as
|
| 291 |
+
|
| 292 |
+
$$
|
| 293 |
+
\nabla _ { W } L _ { b a t c h } = \delta _ { 1 } \pmb { x } _ { 1 } ^ { T } + \delta _ { 2 } \pmb { x } _ { 2 } ^ { T } + . . . + \delta _ { n } \pmb { x } _ { n } ^ { T } .
|
| 294 |
+
$$
|
| 295 |
+
|
| 296 |
+
The gradient update will remain in the subspace spanned by the $n$ input examples.
|
| 297 |
+
|
| 298 |
+
# B.2 ALGORITHM PSEUDO CODE
|
| 299 |
+
|
| 300 |
+
# Algorithm 1 Algorithm for Continual Learning with GPM
|
| 301 |
+
|
| 302 |
+
1: function TRAIN $( f _ { W } , { \mathcal { D } } ^ { t r a i n } , \alpha , \epsilon _ { t h } )$
|
| 303 |
+
2: Initialize, $M ^ { l } \gets [ ]$ , for all $l = 1 , 2 , . . . . L$ // till L-1 if multi-head setting
|
| 304 |
+
3: $\mathcal { M } \{ ( M ^ { l } ) _ { l = 1 } ^ { L } \}$
|
| 305 |
+
4: $W W _ { 0 }$
|
| 306 |
+
5: for $\tau \in { 1 , 2 , . . . . . , T }$ do
|
| 307 |
+
6: repeat
|
| 308 |
+
7: $\mathbf { \bar { \boldsymbol { B } } } _ { n } \sim \mathcal { D } _ { \tau } ^ { t r a i n }$ // sample a mini-batch of size $n$ from task $\tau$
|
| 309 |
+
8: gradient, $\nabla _ { W } L _ { \tau } \gets \mathrm { S G D } ( B _ { n } , f _ { W } )$
|
| 310 |
+
9: $\nabla _ { W } L _ { \tau } \gets \mathrm { P R O J E C T } ( \nabla _ { W } L _ { \tau } , \mathcal { M } )$ // see equation (6, 7)
|
| 311 |
+
10: $\pmb { W } \pmb { W } - \alpha \nabla _ { \pmb { W } } L _ { \tau }$
|
| 312 |
+
11: until convergence
|
| 313 |
+
12:
|
| 314 |
+
13: // Update Memory (GPM)
|
| 315 |
+
14: $\bar { B _ { n _ { s } } } \sim \mathcal { D } _ { \tau } ^ { t r a i n }$ $/ /$ sample a mini-batch of size $n _ { s }$ from task $\tau$
|
| 316 |
+
15: // construct representation matrices for each layer by forward pass (section 5)
|
| 317 |
+
16: $\mathscr { R } _ { \tau } \gets \mathrm { f o r w a r } \mathbf { \bar { d } } ( B _ { n _ { s } } , f _ { W } )$ , where $\mathcal { R } _ { \tau } = \{ ( { \bf R } _ { \tau } ^ { l } ) _ { l = 1 } ^ { L } \}$
|
| 318 |
+
17: for layer, $l = 1 , 2 , . . . L$ do
|
| 319 |
+
18: $\hat { R } _ { \tau } ^ { l } \gets \mathrm { P R O J E C T } ( R _ { \tau } ^ { l } , M ^ { l } )$ // see equation (8)
|
| 320 |
+
19: $\hat { U } _ { \tau } ^ { l } \gets \mathrm { S V D } ( \hat { R } _ { \tau } ^ { l } )$
|
| 321 |
+
20: k ← criteria $( \hat { R } _ { \tau } ^ { l } , R _ { \tau } ^ { l } , \epsilon _ { t h } ^ { l } )$ // see equation (9)
|
| 322 |
+
21: $M ^ { l } \gets [ M ^ { l } , \hat { { \boldsymbol { U } } } _ { \tau } ^ { l } [ 0 : k ] ]$
|
| 323 |
+
22: end for
|
| 324 |
+
23: end for
|
| 325 |
+
24: return $f _ { W } , { \mathcal { M } }$
|
| 326 |
+
25: end function
|
| 327 |
+
|
| 328 |
+
# C EXPERIMENTAL DETAILS
|
| 329 |
+
|
| 330 |
+
# C.1 DATASET STATISTICS
|
| 331 |
+
|
| 332 |
+
Table 4 and Table 5 show the summary of the datasets used in the experiments.
|
| 333 |
+
|
| 334 |
+
Table 4: Dataset Statistics.
|
| 335 |
+
|
| 336 |
+
<table><tr><td></td><td>PMNIST</td><td>Split CIFAR-100</td><td>Split-miniImageNet</td></tr><tr><td>num.of tasks</td><td>10</td><td>10</td><td>20</td></tr><tr><td>input size</td><td>1×28×28</td><td>3 × 32 × 32</td><td>3 × 84×84</td></tr><tr><td># Classes/task</td><td>10</td><td>10</td><td>5</td></tr><tr><td># Training samples/tasks</td><td>54,000</td><td>4,750</td><td>2,375</td></tr><tr><td># Validation Samples/tasks</td><td>6.,000</td><td>250</td><td>125</td></tr><tr><td># Test samples/tasks</td><td>10,000</td><td>1,000</td><td>500</td></tr></table>
|
| 337 |
+
|
| 338 |
+
Table 5: 5-Datasets Statistics. For the datasets with monochromatic images, we replicate the image across all RGB channels so that size of each image becomes $3 \times 3 2 \times 3 2$ .
|
| 339 |
+
|
| 340 |
+
<table><tr><td></td><td>CIFAR-10</td><td>MNIST</td><td>SVHN</td><td>Fashion MNIST</td><td>notMNIST</td></tr><tr><td># Classes</td><td>10</td><td>10</td><td>10</td><td>10</td><td>10</td></tr><tr><td># Training samples</td><td>47,500</td><td>57,000</td><td>69,595</td><td>57,000</td><td>16,011</td></tr><tr><td># Validation Samples</td><td>2,500</td><td>3.000</td><td>3,662</td><td>3,000</td><td>842</td></tr><tr><td># Test samples</td><td>10,000</td><td>10,000</td><td>26,032</td><td>10,000</td><td>1,873</td></tr></table>
|
| 341 |
+
|
| 342 |
+
# C.2 ARCHITECTURE DETAILS
|
| 343 |
+
|
| 344 |
+
AlexNet-like architecture: This is the same architecture used by Serra et al. (2018) with batch \` normalization added in each layer except the classifier layer. The network consists of 3 convolutional layers of 64, 128, and 256 filters with $4 \times 4$ , $3 \times 3$ , and $2 \times 2$ kernel sizes, respectively, plus two fully connected layers of 2048 units each. Rectified linear units is used as activations, and $2 \times 2$ max-pooling after the convolutional layers. Dropout of 0.2 is used for the first two layers and 0.5 for the rest.
|
| 345 |
+
|
| 346 |
+
Reduced ResNet18 architecture: This is the similar architecture used by Lopez-Paz & Ranzato (2017). For miniImageNet experiment, we use convolution with stride 2 in the first layer. For both miniImageNet and 5-Datasets experiments we replace the $4 \times 4$ average-pooling before classifier layer with $2 \times 2$ average-pooling.
|
| 347 |
+
|
| 348 |
+
All the networks use ReLU in the hidden units and softmax with cross entropy loss in the final layer.
|
| 349 |
+
|
| 350 |
+
# C.3 CIFAR-100 SUPERCLASS EXPERIMENT
|
| 351 |
+
|
| 352 |
+
For this experiment, similar to APD (Yoon et al., 2020), we use a modified LeNet-5 architecture with 20-50-800-500 neurons. All the baseline results are reported from APD. Like APD, we do not use any data augmentation or preprocessing. We keep $5 \%$ of training data from each task for validation. We train the network with our algorithm with batch size of 64 and initial learning rate of 0.01. We Train each task for a maximum of 50 epochs with decay schedule and early termination strategy similar to Serra et al. (2018). We use \` $\epsilon _ { t h } = 0 . 9 8$ for all the layers and increasing the value of $\epsilon _ { t h }$ by 0.001 for each new tasks.
|
| 353 |
+
|
| 354 |
+
# C.4 BASELINE IMPLEMENTATIONS
|
| 355 |
+
|
| 356 |
+
GEM (Lopez-Paz & Ranzato, 2017), A-GEM (Chaudhry et al., 2019a), ER Res (Chaudhry et al., 2019b) and OWM (Zeng et al., 2018) are implemented from their respective official implementations. EWC and HAT are implemented from the official implementation provided by Serra et al. \` (2018). While, OGD is implemented from adapting the code provided by Bennani et al. (2020).
|
| 357 |
+
|
| 358 |
+
# C.5 THRESHOLD HYPERPARAMETER
|
| 359 |
+
|
| 360 |
+
As discussed in section 5 and section 7, the threshold hyperparameter, $\epsilon _ { t h }$ controls the degree of interference through the approximation of space of significant representations of the past tasks. Since in neural network, characteristics of learned representations vary for different architectures and different dataset, using the same value of $\epsilon _ { t h }$ may not be useful in capturing the similar space of significance. In our experiments we use $\epsilon _ { t h }$ in the range of 0.95 to 1. For PMNIST experiment, as discussed in section 7, we use $\epsilon _ { t h } = 0 . 9 5$ in the first layer and 0.99 in the other layers. For split CIFAR-100 experiment, we use $\epsilon _ { t h } = 0 . 9 7$ for all the layers and increasing the value of $\epsilon _ { t h }$ by 0.003 for each new tasks. For split miniImageNet experiment, we use $\epsilon _ { t h } = 0 . 9 8 5$ for all the layers and increasing the value of $\epsilon _ { t h }$ by 0.0003 for each new tasks. For experiment with 5-Datasets, we use $\epsilon _ { t h } = 0 . 9 6 5$ for all the layers across all the tasks.
|
| 361 |
+
|
| 362 |
+
# C.6 TRAINING TIME MEASUREMENT
|
| 363 |
+
|
| 364 |
+
We measured per epoch training times (in Figure 2(b)) for computation in NVIDIA GeForce GTX 1060 GPU. For ten sequential tasks in PMNIST experiment, we computed per epoch training time for each task and reported the average value over all the tasks.
|
| 365 |
+
|
| 366 |
+
Training time for different algorithms reported in Table 2(a) for PMNIST tasks were measured on a Single NVIDIA GeForce GTX 1060 GPU. For all the other datasets, training time for different algorithms reported in Table 2(b) were measured on a Single NVIDIA GeForce GTX 1080 Ti GPU.
|
| 367 |
+
|
| 368 |
+
# C.7 LIST OF HYPERPARAMETERS
|
| 369 |
+
|
| 370 |
+
Table 6: List of hyperparameters for the baselines and our approach. Here, ‘lr’ represents (initial) learning rate. In the table we represent PMNIST as ‘perm’, 10-Split CIFAR-100 as ‘cifar’, Split miniImageNet as ‘minImg’ and 5-Datasets as ‘5data’.
|
| 371 |
+
|
| 372 |
+
<table><tr><td>Methods</td><td>Hyperparameters</td></tr><tr><td rowspan="2">OGD</td><td>lr : 0.001 (perm)</td></tr><tr><td># stored gradients :200/task (perm)</td></tr><tr><td>OWM</td><td>lr : 0.01 (cifar), 0.3 (perm)</td></tr><tr><td rowspan="3">GEM</td><td>lr : 0.1 (perm)</td></tr><tr><td>memory size (samples) :100o (perm)</td></tr><tr><td>memory strength, y : 0.5 (perm)</td></tr><tr><td rowspan="2">A-GEM</td><td>lr : 0.05 (cifar), 0.1 (perm, minImg, 5data)</td></tr><tr><td>memory size (samples) : 1000 (perm),2000 (cifar), 500 (minImg), 3000 (5data)</td></tr><tr><td rowspan="2">ER_Res</td><td>lr : 0.05 (cifar), 0.1 (perm, minImg, 5data)</td></tr><tr><td>memory size (samples) :1000 (perm),2000 (cifar), 500 (minImg),3000 (5data)</td></tr><tr><td rowspan="2">EWC</td><td>lr : 0.03 (perm, minImg, 5data), 0.05 (cifar)</td></tr><tr><td>regularization coeficient : 100o (perm), 50oo (cifar, minImg, 5data)</td></tr><tr><td rowspan="3">HAT</td><td>lr : 0.03 (minImg), 0.05 (cifar), 0.1 (5data)</td></tr><tr><td>Smax : 400 (cifar, minImg,5data)</td></tr><tr><td>c : 0.75 (cifar, minImg,5data)</td></tr><tr><td>Multitask</td><td>lr : 0.05 (cifar), 0.1 (perm, minImg,5data)</td></tr><tr><td rowspan="2">GPM (ours)</td><td>lr : 0.01 (perm, cifar), O0.1 (minImg, 5data)</td></tr><tr><td>ns : 100 (minImg,5data),125 (cifar), 300 (perm)</td></tr></table>
|
| 373 |
+
|
| 374 |
+
# C.8 GPM SIZE
|
| 375 |
+
|
| 376 |
+
As discussed in section 4, the gradient update will lie in the span of input vectors $( { \pmb x } )$ in fully connected layers, whereas the gradient updates of the convolutional filters will lie in the space spanned by the input patch vectors $( p )$ . Therefore, each basis stored in the GPM for a particular layer, $l$ will have the same dimension as $\mathbf { \Delta } _ { \mathbf { x } } l$ or $p ^ { l }$ . Thus, for any particular layer, GPM matrix, $M ^ { l }$ can have a maximum size of : $\mathrm { s i z e } ( { \pmb x } ^ { l } ) \times \mathrm { s i z e } ( { \pmb x } ^ { l } )$ or $\mathrm { s i z e } ( p ^ { l } ) \ \times \ \mathrm { s i z e } ( p ^ { l } )$ . Maximum size of the GPM, which we refer as GPM Max, is computed by including GPM matrices $( M ^ { l } )$ from all the layers. Thus the size of GPM Max is fixed by the choice of network architecture. In Table 7, we show the maximum size of GPM matrix $( M ^ { l } )$ for each layers for the architectures that we have used in our experiments along with the size of GPM Max.
|
| 377 |
+
|
| 378 |
+
Table 7: Size of GPM matrices for each layer for the architectures used in our experiments. Maximum sizes of the GPM in terms of number of parameters are also given.
|
| 379 |
+
|
| 380 |
+
<table><tr><td>Network</td><td>Size of maximum Ml</td><td>GPM_Max (parameters)</td></tr><tr><td>MLP (3 layers)</td><td>784 × 784,100 × 100,100 × 100</td><td>0.63M</td></tr><tr><td>AlexNet (5 layers)</td><td>48 × 48,576 × 576,512 × 512, 1024 × 1024,2048 × 2048</td><td>5.84M</td></tr><tr><td>ResNet18 (17 layers+ 3 short-cut connections)</td><td>27 × 27,180 × 180,180 × 180,180 × 180,180 × 180, 180 × 180,360 × 360,20 × 20,360 × 360,360 × 360, 360 × 360,720 × 720,40 × 40,720 × 720,720 × 720, 720 × 720,1440 × 1440,80 × 80,1440 × 1440,</td><td>8.98M</td></tr></table>
|
| 381 |
+
|
| 382 |
+
# D ADDITIONAL RESULTS
|
| 383 |
+
|
| 384 |
+
# D.1 RESULT TABLES
|
| 385 |
+
|
| 386 |
+
Table 8 contains the additional results for PMNIST experiment in single-epoch setting along with the standard deviation values for the results shown in Table 1(a) for multi-epoch (5 epoch) setting. Method that does not adhere to CL setup is indicated by $( ^ { * } )$ in the table. Results are reported from 5 different runs.
|
| 387 |
+
|
| 388 |
+
Table 8: Continual learning on PMNIST in single-epoch and multi-epoch setting.
|
| 389 |
+
|
| 390 |
+
<table><tr><td></td><td colspan="2">1 Epoch</td><td colspan="2">5 Epochs</td></tr><tr><td>Methods</td><td>ACC (%)</td><td>BWT</td><td>ACC (%)</td><td>BWT</td></tr><tr><td>OGD</td><td>85.18 ± 0.29</td><td>- 0.06 ± 0.00</td><td>82.56 ± 0.66</td><td>- 0.14 ± 0.01</td></tr><tr><td>OWM</td><td>90.55 ± 0.15</td><td>- 0.01± 0.00</td><td>90.71 ± 0.11</td><td>- 0.01± 0.00</td></tr><tr><td>GEM</td><td>88.65 ± 0.27</td><td>-0.07±0.00</td><td>83.38 ± 0.56</td><td>- 0.15 ± 0.01</td></tr><tr><td>A-GEM</td><td>87.80 ± 0.16</td><td>- 0.08 ±0.00</td><td>83.56± 0.16</td><td>- 0.14 ±0.00</td></tr><tr><td>ER_Res</td><td>90.63 ± 0.27</td><td>- 0.05 ±0.00</td><td>87.24 ± 0.53</td><td>- 0.11 ± 0.01</td></tr><tr><td>EWC</td><td>88.27 ± 0.39</td><td>- 0.04 ± 0.01</td><td>89.97 ± 0.57</td><td>- 0.04 ± 0.01</td></tr><tr><td>GPM (ours)</td><td>91.74 ± 0.15</td><td>- 0.03 ±0.00</td><td>93.91 ± 0.16</td><td>-0.03 ±0.00</td></tr><tr><td>Multitask*</td><td>95.21 ± 0.01</td><td></td><td>96.70 ± 0.02</td><td></td></tr></table>
|
| 391 |
+
|
| 392 |
+
Table 9: Continual learning on different datasets along with the standard deviation values for the results shown in Table 1(b).
|
| 393 |
+
|
| 394 |
+
<table><tr><td></td><td colspan="2">CIFAR-100</td><td colspan="2">miniImageNet</td><td colspan="2">5-Datasets</td></tr><tr><td>Methods</td><td>ACC (%)</td><td>BWT</td><td>ACC (%)</td><td>BWT</td><td>ACC (%)</td><td>BWT</td></tr><tr><td>OWM</td><td>50.94 ± 0.60</td><td>- 0.30± 0.01</td><td></td><td></td><td></td><td></td></tr><tr><td>EWC</td><td>68.80 ± 0.88</td><td>- 0.02 ± 0.01</td><td>52.01 ± 2.53</td><td>- 0.12 ±0.03</td><td>88.64 ± 0.26</td><td>- 0.04 ± 0.01</td></tr><tr><td>HAT</td><td>72.06 ± 0.50</td><td>-0.00±0.00</td><td>59.78 ± 0.57</td><td>- 0.03 ± 0.00</td><td>91.32 ± 0.18</td><td>-0.01± 0.00</td></tr><tr><td>A-GEM</td><td>63.98 ± 1.22</td><td>- 0.15 ± 0.02</td><td>57.24 ± 0.72</td><td>- 0.12 ± 0.01</td><td>84.04 ±0.33</td><td>-0.12 ± 0.01</td></tr><tr><td>ER_Res</td><td>71.73 ± 0.63</td><td>-0.06 ± 0.01</td><td>58.94 ± 0.85</td><td>- 0.07 ± 0.01</td><td>88.31 ± 0.22</td><td>-0.04 ±0.00</td></tr><tr><td>GPM (ours)</td><td>72.48 ± 0.40</td><td>-0.00 ±0.00</td><td>60.41 ± 0.61</td><td>- 0.00 ±0.00</td><td>91.22 ± 0.20</td><td>- 0.01 ± 0.00</td></tr><tr><td>Multitask*</td><td>79.58± 0.54</td><td>-</td><td>69.46 ± 0.62</td><td>-</td><td>91.54 ± 0.28</td><td>-</td></tr></table>
|
| 395 |
+
|
| 396 |
+
# D.2 k VALUES
|
| 397 |
+
|
| 398 |
+
Table 10 (a) and (b) show the number of new bases added at each layer per PMNIST and 10-split CIFAR-100 task respectively. Total number of bases in the GPM after learning all the tasks is also given.
|
| 399 |
+
|
| 400 |
+
Table 10: Number of new bases $( k )$ added to the GPM at different layers after each (a) PMNIST task and (b) 10-split CIFAR-100 task (for a random seed configuration).
|
| 401 |
+
|
| 402 |
+
<table><tr><td colspan="4">(a)</td><td colspan="7">(b)</td></tr><tr><td></td><td colspan="3">k</td><td></td><td></td><td colspan="4">k</td><td></td></tr><tr><td>Task ID</td><td>FC1</td><td>FC2</td><td>FC3</td><td>Task ID</td><td>Eth</td><td>Conv1</td><td>Conv2</td><td>Conv3</td><td>FC1</td><td>FC2</td></tr><tr><td>1</td><td>81</td><td>60</td><td>41</td><td>1</td><td>0.970</td><td>7</td><td>125</td><td>197</td><td>80</td><td>98</td></tr><tr><td>2</td><td>71</td><td>22</td><td>19</td><td>2</td><td>0.973</td><td>3</td><td>44</td><td>74</td><td>81</td><td>101</td></tr><tr><td>3</td><td>70</td><td>11</td><td>11</td><td>3</td><td>0.976</td><td>0</td><td>20</td><td>29</td><td>71</td><td>93</td></tr><tr><td>4</td><td>61</td><td>4</td><td>7</td><td>4</td><td>0.979</td><td>1</td><td>21</td><td>26</td><td>76</td><td>99</td></tr><tr><td>5</td><td>57</td><td>2</td><td>4</td><td>5</td><td>0.982</td><td>2</td><td>33</td><td>28</td><td>73</td><td>98</td></tr><tr><td>6</td><td>50</td><td>1</td><td>2</td><td>6</td><td>0.985</td><td>0</td><td>16</td><td>19</td><td>71</td><td>98</td></tr><tr><td>7</td><td>46</td><td>0</td><td>2</td><td>7</td><td>0.988</td><td>0</td><td>16</td><td>14</td><td>71</td><td>99</td></tr><tr><td>8</td><td>41</td><td>0</td><td>1</td><td>8</td><td>0.991</td><td>2</td><td>41</td><td>26</td><td>76</td><td>104</td></tr><tr><td>9</td><td>35</td><td>0</td><td>1</td><td>9</td><td>0.994</td><td>6</td><td>56</td><td>34</td><td>84</td><td>109</td></tr><tr><td>10</td><td>31</td><td>0</td><td>0</td><td>10</td><td>0.997</td><td>1</td><td>45</td><td>26</td><td>86</td><td>113</td></tr><tr><td>Total</td><td>543</td><td>100</td><td>88</td><td></td><td>Total</td><td>22</td><td>417</td><td>473</td><td>769</td><td>1012</td></tr></table>
|
| 403 |
+
|
| 404 |
+
Table 11: Continual learning of Digit dataset tasks in class-incremental learning setup (Kamra et al., 2017). (†) denotes the result reported from DGDMN.
|
| 405 |
+
|
| 406 |
+
<table><tr><td></td><td colspan="4">Methods</td></tr><tr><td>Metric</td><td>EWCt</td><td>DGR†</td><td>DGDMNt</td><td>GPM (ours)</td></tr><tr><td>ACC (%)</td><td>10.00</td><td>59.60</td><td>81.80</td><td>70.67</td></tr><tr><td>BWT</td><td>- 1.00</td><td>- 0.43</td><td>- 0.15</td><td>- 0.26</td></tr></table>
|
| 407 |
+
|
| 408 |
+
# D.3 CLASS-INCREMENTAL LEARNING
|
| 409 |
+
|
| 410 |
+
In this section, we evaluate our algorithm in a class-incremental learning setup (Rebuffi et al., 2017), where disjoint classes are learned one by one and classification is performed within all the learned classes without task hint (Kamra et al., 2017). This setup is different (Hsu et al., 2018) from the (single-head/multi-head) evaluation setups used throughout this paper. Also, this scenario is very challenging and often infeasible for the regularization (HAT, EWC etc.) and expansion-based (DEN, APD etc.) methods which do not use old data replay. Using the experimental setting similar to DGDMN (Kamra et al., 2017), we implemented the ‘Digit dataset’ experiment where a single class of MNIST digit is learned per task. Results are listed in Table 11, where the baselines are reported from DGDMN. While EWC forgets catastrophically, we perform better than DGR (Shin et al., 2017), which employs data replay through old data generation. DGDMN, an improved data replay method, outperforms all. In this setup, we believe a subset of old data replay either from storage or via generation is inevitable for attaining better performance with minimal forgetting (Rebuffi et al., 2017; Rajasegaran et al., 2019).
|
| 411 |
+
|
| 412 |
+

|
| 413 |
+
D.4 ADDITIONAL PLOTS
|
| 414 |
+
|
| 415 |
+

|
| 416 |
+
Figure 4: Evolution of task 1 accuracy over the course of incremental learning of 20 sequential tasks from miniImageNet dataset. Learned accuracy in our method remains stable throughout learning.
|
| 417 |
+
Figure 5: Illustration of how threshold hyperparameter controls the degree of interference at (a) Conv layer 1 (b) Conv layer 3 (c) FC layer 1 with the histogram plots of interference activations from Split CIFAR-100 experiment. With increasing $\epsilon _ { t h }$ , spread of the inference activation decreases resulting in minimization of forgetting.
|
md/train/3RMnfrH_Fi8eU/3RMnfrH_Fi8eU.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fast Training of Convolutional Networks through FFTs
|
| 2 |
+
|
| 3 |
+
Michael Mathieu Courant Institute of Mathematical Sciences New York University mathieu@cs.nyu.edu
|
| 4 |
+
|
| 5 |
+
Mikael Henaff Courant Institute of Mathematical Sciences New York University mbh305@nyu.edu
|
| 6 |
+
|
| 7 |
+
Yann LeCun Courant Institute of Mathematical Sciences New York University yann@cs.nyu.edu
|
| 8 |
+
|
| 9 |
+
# Abstract
|
| 10 |
+
|
| 11 |
+
Convolutional networks are one of the most widely employed architectures in computer vision and machine learning. In order to leverage their ability to learn complex functions, large amounts of data are required for training. Training a large convolutional network to produce state-of-the-art results can take weeks, even when using modern GPUs. Producing labels using a trained network can also be costly when dealing with web-scale datasets. In this work, we present a simple algorithm which accelerates training and inference by a significant factor, and can yield improvements of over an order of magnitude compared to existing state-of-the-art implementations. This is done by computing convolutions as pointwise products in the Fourier domain while reusing the same transformed feature map many times. The algorithm is implemented on a GPU architecture and addresses a number of related challenges.
|
| 12 |
+
|
| 13 |
+
# 1 Introduction
|
| 14 |
+
|
| 15 |
+
As computer vision and machine learning aim to solve increasingly challenging tasks, models of greater complexity are required. This in turn requires orders of magnitude more data to take advantage of these powerful models while avoiding overfitting. While early benchmark datasets in machine learning contained thousands or tens of thousands of samples [7, 3, 10], current datasets are of the order of millions [6, 2]. This brings about new challenges as to how to train networks in a feasible amount of time. Even using parallel computing environments, training a network on ImageNet can take weeks [8]. In addition, although inference of labels using a trained network is comparatively fast, real-world applications such as producing labels for all images on the internet can represent a significant cost in terms of time and resources. Therefore, there is an important need to develop fast algorithms for training and inference.
|
| 16 |
+
|
| 17 |
+
In this work, we present a simple algorithm which accelerates training and inference using convolutional networks. The idea is based on performing convolutions as products in the Fourier domain, and reusing transformed feature maps many times. The significant operations in training convolutional networks can all be viewed as convolutions between pairs of 2-D matrices, which can represent input and output feature maps, gradients of the loss with respect to feature maps, or weight kernels. Typically, convolutions are performed for all pairings between two sets of 2-D matrices. By computing the Fourier transforms of the matrices in each set once, we can efficiently perform all convolutions as pairwise products.
|
| 18 |
+
|
| 19 |
+
Although it has long been known that convolutions can be computed as products in the Fourier domain, until recently the number of feature maps used in convolutional networks has been too small to make a method like ours effective. Previous work in the 90’s [1] explored the possibility of using FFTs to accelerate inference at the first layer of a trained network, where the Fourier transforms of the filters could be precomputed offline. However, this was not used during training, possibly because the number of feature maps used at the time was too small to make the overhead of computing FFTs at every iteration worthwhile. When the number of feature maps is large, as is the case for modern convolutional networks, using FFTs accelerates training and inference by a significant factor and can lead to a speedup of over an order of magnitude.
|
| 20 |
+
|
| 21 |
+
# 2 Theory
|
| 22 |
+
|
| 23 |
+
# 2.1 Backpropagation
|
| 24 |
+
|
| 25 |
+
The backpropagation algorithm [9] is the standard method to compute the gradient when training a convolutional network. During training, each layer performs three tasks, which we now describe. First we fix some notation: for a given layer, we have a set of input feature maps $x _ { f }$ indexed by $f$ , each one being a 2-D image of dimensions $n \times n$ . The output is a set of feature maps $y _ { f ^ { \prime } }$ indexed by $f ^ { \prime }$ , which are also 2-D images whose dimension depends on the convolutional kernel and its stride. The layer’s trainable parameters consist of a set of weights $w _ { f ^ { \prime } f }$ , each of which is a small kernel of dimensions $k \times k$ .
|
| 26 |
+
|
| 27 |
+
In the forward pass, each output feature map is computed as a sum of the input feature maps convolved with the corresponding trainable weight kernel:
|
| 28 |
+
|
| 29 |
+
$$
|
| 30 |
+
y _ { f ^ { \prime } } = \sum _ { f } x _ { f } * w _ { f ^ { \prime } f }
|
| 31 |
+
$$
|
| 32 |
+
|
| 33 |
+
During the backward pass, the gradients with respect to the inputs are computed by convolving the transposed weight kernel with the gradients with respect to the outputs:
|
| 34 |
+
|
| 35 |
+
$$
|
| 36 |
+
\frac { \partial L } { \partial x _ { f } } = \frac { \partial L } { \partial y _ { f ^ { \prime } } } * w _ { f ^ { \prime } f } ^ { T }
|
| 37 |
+
$$
|
| 38 |
+
|
| 39 |
+
This step is necessary for computing the gradients in (3) for the previous layer. Finally, the gradients of the loss with respect to the weight are computed by convolving each input feature map with the gradients with respect to the outputs:
|
| 40 |
+
|
| 41 |
+
$$
|
| 42 |
+
\frac { \partial L } { w _ { f ^ { \prime } f } } = \frac { \partial L } { \partial y _ { f ^ { \prime } } } * x _ { f }
|
| 43 |
+
$$
|
| 44 |
+
|
| 45 |
+
Note that $\frac { \partial L } { \partial y _ { f ^ { \prime } } }$ is a 2-D matrix with the same dimensions as the output feature map $y _ { f ^ { \prime } }$ , and that all operations consist of convolutions between various sets of 2-D matrices.
|
| 46 |
+
|
| 47 |
+
# 2.2 Algorithm
|
| 48 |
+
|
| 49 |
+
The well-known Convolution Theorem states that circular convolutions in the spatial domain are equivalent to pointwise products in the Fourier domain. Letting $\mathcal { F }$ denote the Fourier transform and $\bar { \mathcal { F } } ^ { - 1 }$ its inverse, we can compute convolutions between functions $f$ and $g$ as follows:
|
| 50 |
+
|
| 51 |
+
$$
|
| 52 |
+
f * g = { \mathcal { F } } ^ { - 1 } ( { \mathcal { F } } ( f ) \cdot { \mathcal { F } } ( g ) )
|
| 53 |
+
$$
|
| 54 |
+
|
| 55 |
+
Typically, this method is used when the size of the convolution kernel is close to that of the input image. Note that a convolution of an image of size $n \times n$ with a kernel of size $k \times k$ using the direct method requires $( n - k + 1 ) ^ { 2 } k ^ { 2 }$ operations. The complexity of the FFT-based method requires $6 C n ^ { 2 } \log { \dot { n } } + 4 n ^ { 2 }$ operations: each FFT requires $\mathcal { O } ( n ^ { 2 } \log \bar { n _ { . } } ^ { 2 } ) = \mathcal { O } ( 2 n ^ { 2 } \log n ) = 2 C n ^ { 2 } \mathrm { \dot { l o g } } n ,$ , and the pointwise product in the frequency domain requires $4 n ^ { 2 }$ (note that the products are between two complex numbers). Here $C$ represents the hidden constant in the $\mathcal { O }$ notation.
|
| 56 |
+
|
| 57 |
+

|
| 58 |
+
Figure 1: Illustration of the algorithm. Note that the matrix-multiplication involves multiplying all input feature maps by all corresponding kernels.
|
| 59 |
+
|
| 60 |
+
Our algorithm is based on the observation that in all of the operations (1), (2) and (3), each of the matrices indexed by $f$ is convolved with each of the matrices indexed by $f ^ { \prime }$ . We can therefore compute the FFT of each matrix once, and all pairwise convolutions can be performed as products in the frequency domain. Even though using the FFT-based method may be less efficient for a given convolution, we can effectively reuse our FFTs many times which more than compensates for the overhead.
|
| 61 |
+
|
| 62 |
+
The following analysis makes this idea precise. Assume we have $f$ input feature maps, $f ^ { \prime }$ output feature maps, images consisting of $n \times n$ pixels and kernels of $k \times k$ pixels. Also assume we are performing updates over minibatches of size $S$ , and that $C$ represents the hidden constant in the FFT complexity. As an example, using the direct approach (1) will take a total of $S \cdot f ^ { \prime } \cdot f \cdot ( n - k + 1 ) ^ { 2 } \cdot k ^ { 2 }$ operations. Our approach requires $( 2 C \cdot n ^ { 2 } \bar { \log { n } } ) ( S \cdot f + f ^ { \prime } \cdot f )$ operations to transform the input feature maps and kernels to the Fourier domain, a total of $4 S \cdot f ^ { \prime } \cdot \dot { f } \cdot n ^ { 2 }$ additions and multiplications in the Fourier domain, and $S \cdot f ^ { \prime } \cdot ( 2 C \cdot n ^ { 2 } \log n )$ operations to transform the output feature maps back to the spatial domain. The same analysis yields similar complexity estimates for the other operations:
|
| 63 |
+
|
| 64 |
+
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Direct Convolution</td><td rowspan=1 colspan=1>Our Method</td></tr><tr><td rowspan=1 colspan=1>∑fxf*wf'f</td><td rowspan=1 colspan=1>S.f'·f.n'² .k²</td><td rowspan=1 colspan=1>2Cn² logn[f' ·S+ f ·S+f' : f]+4S ·f' · f ·n²</td></tr><tr><td rowspan=1 colspan=1>aL*Tayf</td><td rowspan=1 colspan=1>S.f' · f ·n² .k²</td><td rowspan=1 colspan=1> 2Cn'² logn'[f' ·S+ f·S+f' · f]+4S·f' · f ·n'²</td></tr><tr><td rowspan=1 colspan=1>aL*xfyf</td><td rowspan=1 colspan=1>S.f' · f .k² .n'²</td><td rowspan=1 colspan=1> 2Cnlogn2[f' ·S+ f ·S+ f' · f]+4S ·f' · f ·n²</td></tr></table>
|
| 65 |
+
|
| 66 |
+
Here $n ^ { \prime } = ( n - k + 1 )$ represents the size of the output feature map. Note that the high complexity of the direct method for convolution comes from the product of five terms, whereas our method has a sum of products with at most four terms. Figure 2 shows the theoretical number of operations for direct convolution and our FFT method for various input sizes.
|
| 67 |
+
|
| 68 |
+
# 2.3 Implementation and Memory Considerations
|
| 69 |
+
|
| 70 |
+
Although conceptually straighforward, a number of challenges relating to GPU implementation needed to be addressed. First, current GPU implementations of the FFT such as cuFFT are designed to parallelize over individual transforms. This can be useful for computing a limited number of transforms on large inputs, but is not suitable for our task since we are performing many FFTs over relatively small inputs. Therefore, we developed a custom CUDA implementation of the CooleyTukey FFT algorithm [5] which enabled us to parallelize over feature maps, minibatches and within each 2-D transform. Note that 2-D FFTs lend themselves naturally to parallelization since they can be decomposed into two sets of 1-D FFTs (one over rows and the other over columns), and each set can be done in parallel.
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
Figure 2: Number of operations required for computing (1) with different input image sizes and $S = 1 2 8$ , $f = 9 6$ , $f ^ { \prime } = \bar { 2 } 5 6 , k = 7$ .
|
| 74 |
+
|
| 75 |
+
Second, additional memory is required to store the feature maps in the Fourier domain. Note that by keeping the Fourier representations in memory for all layers after the forward pass, we could avoid recomputing several of the FFTs during the backward pass. However, this might become prohibitively expensive in terms of memory for large networks. Therefore we reuse the same memory for all the different convolutions in the network, so that the necessary amount of memory is determined only by the largest convolution layer. All of the analysis in the previous section and all experiments in the remainder of the paper assume we are using this memory-efficient approach.
|
| 76 |
+
|
| 77 |
+
For a convolution layer taking an input of size $n \times n$ , with $f$ input features, $f ^ { \prime }$ output features and a minibatch of size $S$ , we need to store a total of $S \cdot f + S \cdot f ^ { \prime } + f \cdot f ^ { \prime }$ frequency representations of size $n \times n$ . As another means to save memory, we can use symmetry properties of FFTs of real inputs to store only half the data, i.e. $n ( n + 1 ) / 2$ complex numbers. Assuming float representations, the necessary memory in bytes is:
|
| 78 |
+
|
| 79 |
+
$$
|
| 80 |
+
4 n ( n + 1 ) ( S \cdot f + S \cdot f ^ { \prime } + f \cdot f ^ { \prime } )
|
| 81 |
+
$$
|
| 82 |
+
|
| 83 |
+
The following table shows the amount of RAM used for typical sizes of convolutions:
|
| 84 |
+
|
| 85 |
+
<table><tr><td>S</td><td>n</td><td>f</td><td>f</td><td>RAMused</td></tr><tr><td>128</td><td>16</td><td>96</td><td>256</td><td>76MB</td></tr><tr><td>128</td><td>32</td><td>96</td><td>256</td><td>294MB</td></tr><tr><td>64</td><td>64</td><td>9</td><td>256</td><td>784MB</td></tr><tr><td>128</td><td>64</td><td>96</td><td>256</td><td>1159MB</td></tr><tr><td>128</td><td>16</td><td>256</td><td>384</td><td>151MB</td></tr><tr><td>128</td><td>32</td><td>256</td><td>384</td><td>588MB</td></tr><tr><td>128</td><td></td><td>384</td><td>384</td><td>214MB</td></tr><tr><td>128</td><td>32</td><td>384</td><td>384</td><td>830MB</td></tr></table>
|
| 86 |
+
|
| 87 |
+
Note that this is a relatively small additional memory requirement compared to the total amount of memory used by large networks.
|
| 88 |
+
|
| 89 |
+
# 3 Experiments
|
| 90 |
+
|
| 91 |
+
To test our analysis, we ran a series of experiments comparing our method to the CudaConv GPU implementation of [8] and a custom implementation using the Torch 7 machine learning environment [4]. Both of these implementations compute convolutions using the direct method in the spatial domain. All experiments were performed on the same GeForce GTX Titan GPU. We began by performing unit tests comparing the results of convolutions computed by our method to those computed by the Torch implementation for each of the three operations. We found that the differences in results for operations (1) and (2) to be of the order of $1 0 ^ { - 5 }$ and for operation (3) to be of the order $1 0 ^ { - 4 }$ . The differences are likely due to rounding errors in floating-point operations and are within an acceptable range.
|
| 92 |
+
|
| 93 |
+
We then compared how each method performed in terms of speed with varying kernel sizes, input sizes and minibatch sizes. The results are shown in Figure 3. For all experiments, we chose 96 input feature maps and 256 output feature maps, which represents a typical configuration of a deep network’s second layer. The functions updateOutput, updateGradInput and accGradParameters correspond to the operations in (1), (2) and (3) respectively. All times are measured in seconds.
|
| 94 |
+
|
| 95 |
+
We see that our method significantly outperforms the other two in nearly all cases. The improvement is especially pronounced for the accGradParameters operation, which is the most computationally expensive. This is likely due to the fact that the convolution we are computing has a large kernel, for which FFTs are better suited in any case. Also note that our method performs the same regardless of kernel size, since we pad the kernel to be the same size as the input image before applying the FFT. This enables the use of much larger kernels, which we intend to explore in future work.
|
| 96 |
+
|
| 97 |
+

|
| 98 |
+
|
| 99 |
+

|
| 100 |
+
! &#"&- )%&(& |