Source-linked AI summary

Overcoming catastrophic forgetting with hard attention to the task

Joan Serrà, Dídac Surís, Marius Miron, Alexandros Karatzoglou

arXiv:1801.01423v3cs.LGcs.AIcs.NEstat.ML

TL;DR

Neural networks can forget earlier tasks when trained on new ones. HAT learns task-conditioned hard attention masks to constrain updates and consistently outperformed considered baselines for t≥2, reducing forgetting by 45% at t=8.

  • Problem

    Catastrophic forgetting—the loss of earlier task knowledge after learning new tasks—remains a challenge for neural networks intended to learn sequentially.

    Source: §1 · p. 1
  • Method

    HAT learns almost-binary, task-conditioned attention masks alongside each task and uses prior-task masks to constrain current weight updates.

    Source: §1 · p. 2
  • Results

    Across t≥2, HAT consistently outperformed considered baselines, with forgetting reduced by 45% at t=8.

    Source: §4.1 · p. 7
  • Takeaways & Limitations

    HAT adds only a small fraction of weights, and tuning its two stability- and compactness-related hyperparameters is not crucial for good performance.

    Source: §5 · p. 8

    HAT does not compute input attention for complex signals such as images or audio.

    Source: §2.3 · p. 3

Abstract

from arXiv · show

Catastrophic forgetting occurs when a neural network loses the information learned in a previous task after training on subsequent tasks. This problem remains a hurdle for artificial intelligence systems with sequential learning capabilities. In this paper, we propose a task-based hard attention mechanism that preserves previous tasks' information without affecting the current task's learning. A hard attention mask is learned concurrently to every task, through stochastic gradient descent, and previous masks are exploited to condition such learning. We show that the proposed mechanism is effective for reducing catastrophic forgetting, cutting current rates by 45 to 80%. We also show that it is robust to different hyperparameter choices, and that it offers a number of monitoring capabilities. The approach features the possibility to control both the stability and compactness of the learned knowledge, which we believe makes it also attractive for online learning or network compression applications.

1. Introduction

HAT uses task-conditioned hard attention masks to preserve earlier-task information while learning new tasks, and the paper reports reduced forgetting across four experimental setups.

1. Introduction

  • Catastrophic forgetting erases earlier-task learning during new training, hindering lifelong systems when retraining or concurrent multitask learning is costly.The introduction gives retraining a robot’s model after encountering a new object or task as an example.Source: §1 · p. 1
  • Rehearsal and pseudo-rehearsal retain old-task information by replaying instances, but require concurrent reprocessing; generative networks can replace memory modules (Shin et al., 2017; Nguyen et al., 2017).The introduction notes efficiency and capacity constraints for memory-based approaches and training challenges for generative networks.Source: §1 · p. 1
  • Other strategies reduce representational overlap, using structural regularization (Kirkpatrick et al., 2017) or task-specific network parts (Rusu et al., 2016; Fernando et al., 2017; Yoon et al., 2018).These approaches aim to protect important weights while balancing network capacity across tasks and reusing prior knowledge.Source: §1 · pp. 1–2
  • Across four setups, HAT achieved favorable results on random sequences of eight public datasets against a dozen recent approaches, cutting current rates by 45 to 80%.The paper also reports robustness to hyperparameter choices and monitoring capabilities.Source: §1 · p. 2
  • HAT learns almost-binary attention vectors through gated task embeddings, backpropagation, and minibatch SGD, using previous-task masks to constrain current weight updates.The masks keep some weights static while allowing the rest to adapt to the new task.Source: §1 · p. 2

2. Putting Hard Attention to the Task

HAT uses task identity to condition network layers, aiming to preserve earlier task knowledge while learning new tasks. It learns attention masks and uses them to shape both activations and training updates.

2.2. Architecture

  • HAT conditions each layer with task-specific gated attention masks that activate or deactivate individual units, learning unit-level paths jointly with the network through backpropagation and SGD.Unlike probability-distribution attention, the gates form hard, potentially binary masks.Source: §2.2 · p. 2

2.3. Network Training

  • Cumulative attention from earlier tasks conditions gradients for new tasks, limiting updates to weights associated with units important to those earlier tasks.For image or audio inputs, HAT does not apply attention to the input data itself.Source: §2.3 · p. 3

2.4. Hard Attention Training

  • Annealing the sigmoid scale during training enables gradient flow while progressively hardening attention; setting it to a large smax at test approximates a unit-step gate.Larger smax increases stability for previously learned tasks, while values closer to 1 allow more plasticity and potential forgetting.Source: §2.4 · p. 3

2.5. Embedding Gradient Compensation

  • Embedding gradient compensation counters the annealing scheme’s effects by adjusting embedding gradients to restore a wider range and larger magnitude.The method divides the gradient by the annealed sigmoid derivative and multiplies it by a desired compensation.Source: §2.5 · pp. 3–4

2.6. Promoting Low Capacity Usage

  • HAT adds attention-weighted L1 regularization that favors sparse task masks while excluding units attended in previous tasks, allowing their reuse for the current task.The global constant c controls capacity use and compactness: higher c yields fewer active attention values and a sparser network.Source: §2.6 · p. 4

3. Related Work

The related-work comparison distinguishes HAT’s learned, unit-based attention masks and hard regularization from approaches that use soft weight penalties, task-specific network capacity, or heuristic pruning.

3. Related Work

  • HAT applies hard structural regularization to both loss and gradient magnitudes, learning importance concurrently like SI, while EWC estimates importance after training and both EWC and SI use specific formulations rather than learned masks.IMM extends EWC with a separate model-merging step after learning a task.Source: §3 · p. 4
  • Unlike PNNs’ task-specific columns and adapters or PathNet’s preassigned capacity and evolutionary module paths, HAT learns per-layer widths with weights and uses backpropagation and SGD without fixed modules or solution populations.Source: §3 · pp. 4–5
  • Compared with PackNet’s heuristic pruning and preassigned ratios, HAT learns unit-based masks over weights without fixed pruning ratios; compressibility c controls compactness and smax controls binarization.Source: §3 · p. 5
  • Where DEN uses selective retraining and complex heuristics and hyperparameters, HAT uses two conceptually straightforward hyperparameters and attention-weighted L1 regularization over masks that can plug into existing networks.DEN also uses L1 regularization, L2-transfer, constants, and thresholds to identify drifting units for duplication and retraining.Source: §3 · p. 5

4. Experiments

Across sequential image-classification tasks, HAT reduces forgetting compared with the strongest baselines and also leads on three alternative setups. The experiments assess performance across multiple datasets and tasks, examine hyperparameter sensitivity, and show how HAT can monitor and compress network capacity.

4. Experiments

  • Across eight image-classification datasets, the experiments randomized task order and repeated sequential training and testing 10 times to estimate forgetting.The datasets ranged from 10 to 100 classes, with training sets of 16,853–73,257 examples and test sets of 1,873–26,032 examples.Source: §4 · pp. 5–6

4.1. Results

  • Among baselines, EWC, PathNet, and PNN performed best, but PathNet and PNN struggled as task sequences grew, while LWF and LFL underperformed or proved sensitive.LWF remained competitive at t = 2 but degraded for t > 2; IMM was similar to or only slightly better than SGD-F, and PathNet and PNN had contrasting early-versus-later learning difficulties.Source: §4.1 · pp. 6–7
  • 75% and 45% forgetting reductions: HAT’s average forgetting ratios were −0.02 after 2 tasks and −0.06 after 8, versus the best baselines’ −0.08 and −0.11.HAT consistently outperformed the considered baselines for all t ≥2, and its standard deviation was lower than that of most baselines.Source: Table 1 · p. 6, §4.1 · p. 7

4.2. Additional Results

  • 55%, 52%, and 80%: HAT reduced forgetting by 55% on incremental classes and error rates by 52% on permuted MNIST and 80% on split MNIST.On incremental classes, HAT’s ρ≤10 was −0.09 versus EWC’s −0.18; on permuted MNIST, HAT’s A≤10 was 98.6% versus SI’s 97.1%; on split MNIST, HAT’s A≤2 was 99.0% versus 94.9% for conceptor-aided backpropagation.Source: §4.2 · p. 7

4.3. Hyperparameters

  • Reasonable performance held across smax ∈[25, 800] and c ∈[0.1, 2.5], with defaults smax = 400 and c = 0.75.Lower smax favors adaptation but risks forgetting; higher smax protects prior learning but can hinder adaptation, while higher c encourages compactness at potential accuracy cost.Source: §4.3 · p. 7

4.4. Monitoring and Network Pruning

  • HAT’s masks support monitoring capacity use and cross-task weight reuse, and enable pruning through backpropagation and SGD alongside weight learning.With c = 1.5 and U(0, 2), HAT compressed networks to 1–21% of original size; on MNIST and CIFAR100, it compressed to 1% and 21%, respectively.Source: §4.4 · pp. 7–8

5. Conclusion · APPENDIX

HAT uses task embeddings and hard attention to protect information from previous tasks while learning new ones. The paper demonstrates its effectiveness in image classification and highlights its lightweight training, tunable stability and compactness, and monitoring capabilities.

5. Conclusion

  • HAT focuses on a task embedding to protect previous-task information while learning new tasks.The paper presents this as a mechanism for controlling catastrophic forgetting.Source: §5 · p. 8
  • The authors demonstrate HAT’s effectiveness against catastrophic forgetting in image classification across multiple datasets and state-of-the-art approaches.Source: §5 · p. 8
  • HAT adds only a small fraction of weights to the base network, making the hard attention mechanism lightweight.Source: §5 · p. 8
  • HAT is trained jointly with the main model using backpropagation and vanilla SGD, with negligible overhead.Source: §5 · p. 8
  • HAT has two hyperparameters, associated with stability and compactness of learned knowledge, and their tuning is not crucial for good performance.Source: §5 · p. 8
  • HAT enables monitoring of network capacity across tasks and layers, unit reuse across tasks, and model compressibility for a given task.Source: §5 · p. 8
  • The authors suggest HAT may also be useful for online learning or network compression, and that hard attention may apply beyond catastrophic forgetting.Source: §5 · p. 8

A. Data

Experiments used eight image datasets spanning handwritten and street-view digits, fashion items, traffic signs, glyphs, faces, and color images, with inputs adapted to the required shape but not augmented.

A. Data

  • The experiments used MNIST, Fashion-MNIST, TrafficSigns, NotMNIST, SVHN, FaceScrub, CIFAR10, and CIFAR100 image datasets.FaceScrub was the MegaFace-hosted version, limited to the 100 people with the most appearances.Source: A. Data · p. 11
  • Inputs were resized, zero-padded, or replicated across RGB channels to match the required shape, without data augmentation.FaceScrub, TrafficSigns, and NotMNIST images were resized; MNIST and Fashion-MNIST were zero-padded; monochromatic images were replicated across RGB channels.Source: A. Data · p. 11

B. Raw Results · B.1. Task Mixture · B.2. Layer Use

The raw results report forgetting ratios across task sequences and describe monitoring layer capacity as tasks evolve. The supplied passages give the reporting scope and monitoring method, but no numerical results.

B.1. Task Mixture

  • Forgetting ratios ρ≤t are reported for t = 1 to 8 in Table 3.The passage does not provide the table’s values.Source: §B.1 · p. 11
  • The forgetting-ratio report averages results and standard deviations across 10 runs with 10 different seeds.Source: §B.1 · p. 11

B.2. Layer Use

  • Layer capacity monitoring can track the percent of active weights for a given layer and task as the task sequence evolves.The passage identifies Fig. 8 as an example of this monitoring.Source: §B.2 · p. 11

B.3. Network Compression

The section reports HAT’s network-compression experiment and the accuracy and network-weight usage measures used to evaluate compression.

B.3. Network Compression

  • Figure 8 shows layer-wise weight usage during sequential task learning, with lines including and bars excluding cumulative attention from past tasks.The task sequence corresponds to seed 0.Source: Figure 8 · p. 12
  • After convergence, Table 4 reports SGD test accuracy A1, post-HAT-compression test accuracy A1, and the percentage of network weights used.The experiment is run on isolated tasks with c = 1.5 and uniform embedding initialization U(0, 2).Source: §B.3 · p. 11, Table 4 · p. 12

B.4. Training Time

HAT is reported as competitive in training time, with reference timings measured on a single GPU across total, per-epoch, and per-batch durations.

B.4. Training Time

  • HAT is quite competitive in training time, according to the reference values reported in Table 5.The table reports wall-clock measurements on a single NVIDIA Pascal Titan X GPU.Source: §B.4 · p. 12, Table 5 · p. 13
  • Table 5 reports total time after learning 8 tasks, per-epoch time, and per-batch time for batches of 64, measuring forward-only and forward-plus-backward passes.The supplied passage gives the measurement scope but not the timing values.Source: Table 5 · p. 13

C. Additional Results · C.1. Incremental CIFAR · C.2. Permuted MNIST

The additional results evaluate incremental CIFAR using average forgetting ratio and permuted MNIST using accuracy after sequential training on pixel-permutation tasks.

C.1. Incremental CIFAR

  • CIFAR10 and CIFAR100 are split into consecutive-class tasks presented in seed-determined random order, using groups of 2 and 20 classes, respectively.Each dataset yields 10 tasks; group sizes were chosen to give a similar number of training instances per task.Source: §C.1 · p. 13
  • For incremental CIFAR, Figure 9 and Table 6 report average forgetting ratio ρ≤t over 10 runs, with standard deviation in parentheses in Table 6.The complete numbers are shown in Figure 9 and Table 6.Source: Figure 9 · p. 13, §C.1 · p. 13, Table 6 · p. 14

C.2. Permuted MNIST

  • Permuted MNIST follows the common pixel-permutation experiment proposed by Srivastava et al. (2013) and later used for catastrophic-forgetting evaluation by Goodfellow et al. (2014).The typical reported measure is average accuracy after sequential training on 10 permutations.Source: §C.2 · p. 13
  • Table 7 reports accuracy after 10 permuted-MNIST tasks, except generative replay, which is assessed after 5 tasks.Its superscripts identify results reported by Nguyen et al. (2017) and He & Jaeger (2018).Source: Table 7 · p. 14
  • Permuted-MNIST comparisons use small, medium, and large two-layer fully connected networks with 100, 500, and 2000 hidden units, respectively.The large network uses dropout probabilities from Kirkpatrick et al. (2017).Source: §C.2 · p. 14
  • The permuted-MNIST settings use smax = 200 and c = 0.5 for the small network, and smax = 400 and c = 0.5 for the medium and large networks.Results for these settings are available in Table 7.Source: §C.2 · p. 14, Table 7 · p. 14

C.3. Split MNIST … E. A Note on Binary Masks

The supplementary sections report the split-MNIST evaluation setup and survey implementation alternatives, noting where they fell short of the main approach or may suit other uses. They also distinguish HAT’s unit-based masks from weight-based binary masks used by other approaches.

C.3. Split MNIST

  • Split-MNIST evaluation followed Lee et al. (2017): labels 0–4 and 5–9 formed two tasks, and the experiment ran 10 times using a matched base architecture.HAT was trained for 50 epochs with c = 0.1; dropout was omitted to match the cited setup, and Table 8 reports average accuracy.Source: §C.3 · p. 14, Table 8 · p. 14

D. Variations to the Proposed Approach; D.1. Embedding Learning

  • Embedding learning rates 10–50 times the original rate performed almost as well as the main-paper results, while adaptive optimizers performed worse and added hyperparameters.Adaptive optimizers learned suitable embedding values, but introduced choices such as optimizer type, learning rate, and weight decay.Source: §D.1 · p. 15

D.2. Annealing

  • The first alternative annealing schedule produced true binary attention vectors at inference and removed smax, but performed worse than the main-paper solution.A second schedule with α = 1 and β < 1 improved results, but still fell short of the main-paper results and required tricky β tuning.Source: §D.2 · p. 15

D.3. Gate

  • A clamped linear gate simplifies gradient compensation, but requires setting r and was not tested quantitatively.Its gradient treats embedding values far from the step transition similarly to values near it, including values in the constant regions.Source: §D.3 · pp. 15–16

D.4. Cumulative Attention

  • The preliminary cumulative-attention formula was replaced by the final max-based formula, though it may suit online learning with limited model capacity.The suggested variant pairs the formula with κ slightly below 1, such as 0.9 or 0.99.Source: §D.4 · p. 16

D.5. Embedding Initialization; D.6. Attention Regularization

  • Alternative embedding initializations U(0, k1) with k1 ∈ [1, 6] and N(k2, 1) with k2 ∈ [0.5, 2] were competitive but worse than N(0, 1); normalized L1 regularization also underperformed the main-paper attention-weighted regularization.L2 regularization gave accuracies similar to L1 under different values of c; the authors suggest U(0, 2) may suit a purely compressive approach.Source: §D.5 · p. 16, §D.6 · p. 16

D.7. Hard Attention to the Input

  • For independent, isolated input features, hard attention on the input may provide supervised feature selection; experiments suggested it could support feature selection and data compression.The paper otherwise reports no input mask for general image classification, particularly for first-layer convolutional filters.Source: §D.7 · p. 16

E. A Note on Binary Masks

Loading 1801.01423v3…