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

Catastrophic forgetting causes neural networks to lose earlier task knowledge during sequential learning, motivating methods that preserve prior information without blocking new learning. HAT learns task-conditioned hard attention masks concurrently with each task and uses previous masks to constrain updates. Across the reported experiments, it reduces forgetting by 45% to 80%, with robustness and monitoring capabilities.

  • Problem

    Catastrophic forgetting causes a network to lose information learned on previous tasks after training on subsequent tasks, hindering sequential and lifelong learning.

  • Method

    HAT jointly learns almost-binary task-attention vectors through backpropagation and uses cumulative previous-task masks to condition current gradient updates.

  • Results

    HAT consistently outperforms the considered baselines across task sequences and reports forgetting reductions of 45% to 80% across four experimental setups.

  • Takeaways & Limitations

    HAT provides a lightweight mechanism for controlling catastrophic forgetting while exposing network-capacity and cross-task weight-reuse monitoring capabilities.

  • Takeaways & Limitations

    The reported training procedure does not apply attention to complex input data such as images or audio.

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

Catastrophic forgetting causes networks trained sequentially to lose earlier task knowledge, limiting lifelong learning. HAT addresses this with task-based hard attention that protects prior information while learning new tasks.

  • Motivation: Catastrophic forgetting is the tendency to lose performance on an earlier task after training on new information.The paper illustrates this with sequential training on two tasks, where learning the second causes the network to forget the first.
  • Motivation: Sequential learning matters for lifelong artificial intelligence because retraining from scratch or concurrent learning can become impractical as tasks accumulate.The paper highlights robots encountering new objects and the cost of multitask learning at scale.
  • Existing approaches: Rehearsal and pseudo-rehearsal preserve prior knowledge by reprocessing old instances, but they require memory or concurrent learning and can face efficiency and capacity constraints.Pseudo-rehearsal may use generated examples, yet training a generative network for task sequences or certain data types is difficult.
  • Existing approaches: Structural regularization reduces representational overlap by discouraging changes to important weights or assigning network sub-parts to different tasks.These strategies trade off distributing network capacity across tasks with preserving important weights and reusing knowledge.
  • Proposed approach: HAT learns task-conditioned, almost-binary attention vectors concurrently with each task and uses previous masks to constrain current weight updates.The approach reports 45% to 80% reductions in current forgetting rates across four experimental setups.

2. Putting Hard Attention to the Task

HAT uses task embeddings to create hard, nearly binary unit masks that condition each layer and preserve previously important network paths. Training combines gradient conditioning, annealed sigmoid gates, compensation, and sparsity regularization to balance stability with future capacity.

  • 2.1. Motivation: HAT conditions every layer on a task identifier so different tasks can use distinct feature paths while retaining reusable knowledge.The motivation is that task identity can distinguish otherwise similar task inputs and guide protection against forgetting.
  • 2.2. Architecture: The architecture gates layer outputs with task-embedding-derived attention rather than forming a probability distribution.The gated mechanism can activate or deactivate individual units and dynamically create paths across layers.
  • 2.3. Network Training: Previous-task attention vectors are accumulated and used to condition gradients, preventing large updates to weights associated with earlier tasks.The gradient mask is expanded across tensor dimensions before element-wise minimum, subtraction, and multiplication operations.
  • 2.4. Hard Attention Training: HAT uses an annealed sigmoid gate during training and a large test-time scaling value so attention approaches a binary unit-step mask.Annealing preserves gradient flow while progressively polarizing unit activity.
  • 2.4. Hard Attention Training: The scaling parameter s_max controls the stability–plasticity trade-off: values near 1 permit forgetting, whereas larger values stabilize previously learned weights.The paper also introduces gradient compensation because annealing changes the range and magnitude of embedding gradients.
  • 2.6. Sparsity: Sparsity regularization encourages attention vectors to reserve unused units for future tasks, making active attention determine task-dedicated capacity.The regularization operates using current and cumulative attention vectors.

3. Related Work

Related approaches protect prior knowledge through soft regularization, preallocated or expandable capacity, or masks. HAT instead learns lightweight, unit-based capacity allocation and hard gradient constraints jointly with the network.

  • Regularization: EWC and SI softly discourage changes to important weights, whereas HAT applies hard structural regularization through both the loss and gradient magnitudes.EWC estimates importance after training, while SI and HAT compute it concurrently.
  • Capacity allocation: PNNs preassign column widths and reuse prior columns, while HAT learns task-dependent layer widths jointly with network weights.HAT adapts allocated capacity to the difficulty of the current task rather than fixing widths in advance.
  • Capacity allocation: PathNet preassigns network capacity per task, while PackNet uses heuristic pruning with fixed pruning ratios and weight-based binary masks.HAT instead uses unit-based masks to constrain weights and potentially use capacity more lightly.
  • Capacity allocation: DEN allocates capacity through selective retraining that combines heuristics, thresholds, duplication, and multiple regularization settings.This contrasts with HAT’s jointly trained task-conditioned mechanism.

4. Experiments

Experiments evaluate catastrophic forgetting across diverse sequential-task setups, showing that HAT consistently outperforms the considered baselines while supporting monitoring and network compression.

  • Evaluation setup: Experiments use eight image-classification datasets, randomized task orders, and repeated evaluations across ten seeds.The evaluation includes multiple task setups, including incremental-class, permuted-MNIST, and split-MNIST scenarios.
  • Baseline comparisons: Baseline performance is inconsistent: LWF degrades beyond two tasks, LFL is hyperparameter-sensitive, and PathNet and PNN suffer from fixed capacity allocation.PathNet and PNN display contrasting learning behavior as task count increases, while neither dynamically allocates network capacity.
  • Main results: HAT consistently outperforms all considered baselines for sequences with t ≥2, reducing forgetting by 75% at t = 2 and 45% at t = 8.At t = 2, HAT achieves ρ≤2 = −0.02 versus EWC’s −0.08; at t = 8, it achieves ρ≤8 = −0.06 versus PNN’s −0.11.
  • Additional results: 55% forgetting reduction is obtained on incremental-class learning, while permuted-MNIST and split-MNIST show 52% and 80% error-rate reductions, respectively.HAT reports ρ≤10 = −0.09 for incremental classes, A≤10 = 98.6% for permuted MNIST, and A≤2 = 99.0% for split MNIST.
  • Monitoring and compression: Hard attention enables monitoring of instantaneous capacity usage, active weights, and weight reuse across tasks.These quantities are estimated from conditioning masks derived from the learned hard attention vectors.
  • Monitoring and compression: HAT compresses networks to 1–21% of their original size, generally below the reported compression rates of PackNet and DEN.The method learns pruning through backpropagation and SGD concurrently with network weights.

5. Conclusion

HAT protects previous-task information while learning new tasks through task-conditioned hard attention. The approach reduces catastrophic forgetting, adds lightweight monitoring, and exposes control over stability and compactness.

  • HAT uses task embeddings and hard attention to protect previous-task information while learning new tasks.The mechanism is trained with the main model using backpropagation and vanilla SGD.
  • HAT adds only a small fraction of weights and incurs negligible training overhead.
  • HAT has two hyperparameters corresponding intuitively to the stability and compactness of learned knowledge.The paper reports that tuning them is not crucial for obtaining good performance.
  • HAT can monitor network capacity across tasks and layers, unit reuse across tasks, and model compressibility.
  • Experiments in image classification demonstrate HAT’s effectiveness against catastrophic forgetting across multiple data sets and state-of-the-art approaches.

A. Data

The study uses several image datasets and adapts their inputs to a common experimental shape. These adaptations involve resizing, zero-padding, and channel replication without data augmentation.

  • The datasets include MNIST, Fashion-MNIST, German traffic signs, and NotMNIST.MNIST contains 28 × 28 monochromatic handwritten-digit images, while Fashion-MNIST contains same-sized grayscale clothing images.
  • Some datasets are resized or zero-padded to match the image input shape required by the experiments.FaceScrub, TrafficSigns, and NotMNIST are resized; MNIST and FashionMNIST are padded with zeros.
  • Monochromatic images are replicated across all RGB channels, and no data augmentation is performed.
  • Table 2 summarizes each dataset’s name, reference, number of classes, and train and test instance counts.

B.1. Task Mixture

The appendix reports forgetting ratios across sequential tasks using repeated seeded runs and illustrates layer-capacity monitoring as tasks accumulate. Capacity is expressed as the percentage of active weights in a layer for a task.

  • Forgetting ratios are reported for tasks t = 1 to 8 using 10 runs with different seeds.Means and standard deviations are computed across the runs.
  • The layer-capacity example tracks network usage as the sequence of tasks evolves.
  • The appendix computes a percentage of active weights for a given layer and task.

B.3. Network Compression

The network-compression experiment evaluates converged HAT models on isolated tasks and reports compression-related results. The appendix also presents layer-wise capacity usage across sequential tasks and identifies the task sequence for seed 0.

  • HAT is run on isolated tasks with c = 1.5 and uniform embedding initialization U(0, 2).These settings are used for the final converged compression results.
  • Table 3 reports average forgetting ratio ρ≤t for the considered approaches with standard deviations from 10 runs.
  • Figure 8 shows layer-wise weight usage with sequential task learning, including and excluding cumulative attention from past tasks.
  • The reported task sequence corresponds to seed 0.
  • The compression experiment reports test accuracy A1 with SGD and test accuracy A1 after compression.
  • Table 4 reports the percentage of network weights used after compression.

B.4. Training Time

HAT is competitive in training time, with wall-clock measurements reported across total, epoch, and batch processing costs.

  • HAT is quite competitive in training time among the considered approaches.Table 5 reports total time after learning 8 tasks, per-epoch time, and forward or forward-backward batch time.

C. Additional Results

The additional evaluation includes incremental CIFAR and permuted MNIST experiments, with results summarized through forgetting ratios and task-specific accuracy measurements.

  • Incremental CIFAR uses 10 consecutive-class tasks formed from CIFAR10 and CIFAR100 subsets presented in random order.The setup uses groups of 2 CIFAR10 classes and 20 CIFAR100 classes.
  • Average forgetting ratio ρ≤t is reported for the incremental CIFAR task after 10 runs.Table 6 includes standard deviations in parentheses.
  • Permuted MNIST evaluates average accuracy after training on 10 tasks, with generative replay assessed after 5 tasks.The table also records parameter counts and indicates results reported by prior studies with superscripts.
  • The permuted-MNIST experiments use small, medium, and large two-layer fully connected networks with 100, 500, and 2000 hidden units.The reported settings include network-size-specific annealing and dropout choices.

C.3. Split MNIST

The split-MNIST and supplementary studies examine HAT training choices, input attention, initialization, regularization, and binary-mask interpretations.

  • C.3. Split MNIST: Split MNIST divides labels 0–4 and 5–9 into two sequential tasks and reports results from 10 runs.HAT is trained for 50 epochs with c = 0.1, and results are reported in Table 8.
  • D.2. Annealing: Alternative annealing schedules can produce truly binary attention vectors at inference time, but the main-paper solution performs better.The alternative with α = 1 and β < 1 improved performance, yet remained below the main-paper results and required tricky β tuning.
  • D.3. Gate: A clamped linear gate simplifies gradient compensation but adds a hyperparameter and was not tested quantitatively.It also treats values near 0 or 1 like values in the transition region.
  • D.5. Initialization: Uniform and shifted-normal embedding initializations produced competitive but worse results than N(0, 1).The alternatives were U(0, k1) with k1 ∈[1, 6] and N(k2, 1) with k2 ∈[0.5, 2].
  • D.6. Attention Regularization: L2 regularization achieved similar accuracies to L1 regularization under different values of c, while normalized L1 was slightly worse than the main-paper regularization.The normalized L1 comparison reported a small percentage decrease.
  • D.7. Hard Attention to the Input: Hard attention at the input may support feature selection and data compression for isolated input features.The authors consider omitting input masks a good strategy for general image classification and first-layer convolutional filters.
  • E. A Note on Binary Masks: HAT learns unit-based attention masks that may be binary, differing from approaches that use weight-based binary masks.The paper relates this distinction to earlier inhibitory-synapse ideas.
Loading 1801.01423v3…