---
title: "Memorizing Normality to Detect Anomaly: Memory-Augmented"
description: "How MemAE uses a sparse memory of normal patterns to expose anomalies, what its experiments establish, and where its conclusions stop."
canonical: "https://research.elamur.ai/free/en/papers/gong-2019-memorizing-normality-detect-anomaly-memory/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/gong-2019-memorizing-normality-detect-anomaly-memory/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2019](https://md.research.elamur.ai/free/en/papers/2019/) / Memorizing Normality to Detect Anomaly: Memory-Augmented Deep Autoencoder for Unsupervised Anomaly Detection

# Memorizing Normality to Detect Anomaly: Memory-Augmented Deep Autoencoder for Unsupervised Anomaly Detection

Paper · 2019 · Dong Gong, Lingqiao Liu, Vuong Le et al.

**Authors:** Dong Gong, [Lingqiao Liu](https://md.research.elamur.ai/free/en/authors/lingqiao-liu/), Vuong Le, Budhaditya Saha, Moussa Reda Mansour, Svetha Venkatesh and [Anton van den Hengel](https://md.research.elamur.ai/free/en/authors/anton-van-den-hengel/) · **Year:** 2019 · **Venue:** IEEE/CVF International Conference on Computer Vision (ICCV) · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[**1,797** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W2987228832) · [IEEE/CVF International Conference on Computer Vision (ICCV)](https://openalex.org/S4363607764) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1904.02639)
- [DOI 10.1109/iccv.2019.00179](https://doi.org/10.1109/iccv.2019.00179)
- [arXiv 1904.02639](https://arxiv.org/abs/1904.02639)
- [OpenAlex](https://openalex.org/W2987228832)

Citations: OpenAlex, 2026-10-14.

## Deep dive: Memorizing Normality to Detect Anomaly: Memory-Augmented Deep Autoencoder for Unsupervised Anomaly Detection

How MemAE uses a sparse memory of normal patterns to expose anomalies, what its experiments establish, and where its conclusions stop. · about 35 minutes to read

**In this deep dive**

1. [Summary](#dd-summary)
2. [Ideas worth borrowing](#dd-ideas-worth-borrowing)
3. [How Mova uses it](#dd-how-mova-uses-it)
4. [The problem and its context](#dd-the-problem-and-its-context)
5. [The method, step by step](#dd-the-method-step-by-step)
6. [Experiments and results](#dd-experiments-and-results)
7. [What the ablations show](#dd-what-the-ablations-show)
8. [Limitations](#dd-limitations)
9. [What came after](#dd-what-came-after)

### Summary

An anomaly detector should notice when an input departs from what it has learned to regard as normal. For a system trained by reconstruction, that means reproducing familiar inputs accurately while making larger errors on unfamiliar ones. The difficulty is that a capable reconstruction network can also reproduce inputs it has never been trained to accept. A pedestrian scene and an unusual vehicle may share enough visual structure for the same network to reconstruct both. A small reconstruction error can therefore conceal an anomaly rather than demonstrate normality.

MemAE addresses this problem by changing what reaches the decoder, the component that rebuilds the input. An ordinary autoencoder passes an encoded representation directly from its encoder to its decoder. MemAE instead uses that representation to search a learned memory. The decoder receives a combination of selected memory entries, which have been trained using normal examples. The intended effect is to make reconstruction depend on familiar patterns: an unusual input must be rebuilt through the normal patterns available in memory, exposing the parts that do not fit.

The important restriction is not simply that memory has limited capacity. MemAE also makes access to that memory sparse, so that reconstruction depends on relatively few entries. Without this restriction, an unusual input might still be reconstructed through a complicated mixture of many normal patterns. The authors combine a thresholding operation, which removes small access weights, with a training penalty that encourages concentrated weights. The encoder, decoder, and memory learn together; after training, the memory remains fixed.

The experiments apply this mechanism to image outliers, unusual video events, and cybersecurity records. The authors report improvements over an ordinary autoencoder and over a memory-equipped version without the sparsity mechanisms. Their visual examples clarify the intended behavior: a network trained on the digit “5” turns an unusual “9” into something resembling a “5,” creating an informative reconstruction mismatch. Video examples similarly show reconstruction errors concentrated around unusual objects. These observations support a specific contribution: controlling the representations available to a decoder can make reconstruction error more useful for anomaly detection. They do not establish that every anomaly must be reconstructed badly, or that memory access alone provides a complete explanation of abnormality.

### Ideas worth borrowing

Constrain the reconstruction route. When reconstruction error serves as a decision signal, accurate reconstruction is not always desirable. MemAE makes the decoder work through a learned collection of normal representations instead of accepting every encoding directly. This idea applies wherever a system should reproduce familiar structure while exposing departures from it. The reusable principle is to shape the path from observation to output according to the decision being made. A reconstruction system intended for anomaly detection needs different generalization behavior from one intended simply to reproduce diverse inputs.

Separate finding from rebuilding. MemAE assigns the encoder the job of producing a search query, while the memory supplies the representation used for reconstruction. This separates the description of the current input from the patterns the system permits itself to use. Such a separation can be useful when an unrestricted internal representation would make a downstream task too easy in the wrong way. It also creates an intermediate object to inspect: which stored patterns were selected before the decoder produced its answer?

Limit combinations as well as capacity. A small store does not necessarily impose a strong restriction if arbitrary mixtures of its contents remain available. The paper identifies dense memory access as a way anomalies might still be reconstructed successfully. Its response is to restrict the mixture itself. This principle extends to systems that combine prototypes, dictionary entries, or retrieved representations. The number of stored elements and the freedom to combine them are different sources of expressive power, and each may need its own control.

Match restrictions during training and testing. MemAE learns its memory under the same sparse access mechanism used when evaluating new inputs. The entries therefore adapt to being useful in small combinations. This is more coherent than learning an unrestricted representation and imposing a severe access restriction only afterward. The broader engineering lesson is to expose a system during training to the constraints under which it will operate. Otherwise, a restriction intended to improve decisions may instead remove information the learned representation expects to use.

Inspect intermediate representations through outputs. The authors decode individual memory entries to examine what they contain. These isolated reconstructions are imperfect, because normal operation combines entries, but they still reveal recognizable patterns. This is a useful approach to [interpretability](https://md.research.elamur.ai/free/en/topics/interpretability/): inspect an internal component through the same output machinery that gives it practical meaning. The result should remain evidence about behavior instead of a claim that every entry has a clean, unique human interpretation.

Use controlled variants to test the explanation. The paper compares full MemAE with an ordinary autoencoder, unrestricted memory access, individual sparsity components, and sparsity applied directly to encoded features. These comparisons ask different questions. They distinguish the effect of adding memory from the effect of controlling access, and both from the more general benefit of regularization. A researcher borrowing the architecture should also borrow this experimental discipline. An improvement is more informative when nearby alternatives test why it occurs.

### How Mova uses it

For Mova, a small transparent language system written in Rust, the most relevant idea is a restricted path through familiar patterns. The paper does not study Mova, and no implemented connection is established here. The following applications are possibilities derived from MemAE’s mechanism, rather than descriptions of a feature already built into Mova.

A possible application is a familiarity check on internal language representations. Mova could maintain a collection of representations learned from material it treats as ordinary for a particular task. A new representation could query that collection, and a restricted combination of retrieved entries could be used to approximate it. A large mismatch would suggest that the input does not fit the remembered patterns well. This would transfer the paper’s central distinction between encoding an input and accepting that encoding as a sufficient basis for reconstruction.

The word “normal” would need a narrow operational meaning. In MemAE, normality comes from the training examples, not from an independent judgment of correctness or acceptability. For a language system, familiar wording could be mistaken, and unfamiliar wording could be entirely valid. A Mova experiment based on this paper would therefore be most defensible as a measure of fit to a chosen reference distribution. It would not automatically become a detector of false claims, bad reasoning, or harmful content.

The memory interface could also suit Mova’s emphasis on transparency. An experimental implementation could expose the query representation, the entries it selected, the weights that survived thresholding, and the resulting approximation error. Those records would show how the familiarity signal was produced. They would not explain every linguistic property of the input, but they could make the route to the signal inspectable. This follows the paper’s use of memory access as an explicit intermediate computation, while extending the inspection to a possible language application.

Sparse access is particularly relevant to that proposal. If a new expression can be approximated through a diffuse mixture of almost everything in memory, its apparent familiarity may be difficult to interpret. Restricting the mixture would make the system commit to a smaller collection of supporting patterns. The paper suggests why such a restriction might sharpen an anomaly signal, but it provides no language experiment establishing that the same outcome would occur in Mova. The representation, reconstruction target, and definition of an unusual case would all require testing.

A useful first investigation would compare an unrestricted reconstruction route with a memory-mediated route under the same language task. It would also compare sparse access with dense access, rather than attributing any improvement to memory alone. The paper’s ablations make this comparison important: the proposed benefit comes from the interaction between remembered patterns and restricted combinations. A Mova implementation that merely adds a searchable store would reproduce only part of the method.

The transfer should therefore remain modest and concrete. MemAE offers a candidate architecture for asking whether an internal representation can be explained through a limited collection of familiar representations. It does not supply a ready-made linguistic anomaly criterion, and it does not establish that its learned entries would correspond to words, constructions, meanings, or grammatical rules. Those would be questions for a Mova experiment, with the intermediate memory operations available for inspection.

### The problem and its context

#### Why reconstruction can give the wrong reassurance

The paper studies anomaly detection under a normal-only training regime. Training examples describe the accepted distribution, and the system must later identify inputs that depart from it. There are no abnormal training examples to teach a direct boundary between all acceptable and unacceptable cases. The system must infer that boundary from its account of normality.

An autoencoder offers an appealing way to build such an account. Its encoder compresses an input into a latent representation: an internal description with less direct detail than the original observation. Its decoder attempts to recover the observation from that description. Training minimizes the mismatch between input and reconstruction. The compression encourages the network to capture recurring structure rather than simply treating every input coordinate independently.

For anomaly detection, the usual reasoning adds another step. If training contains only normal examples, the network should become good at reconstructing normal structure. An unusual input should fit that learned structure poorly and therefore produce a larger error. Reconstruction error can then serve as the anomaly score.

The authors challenge the reliability of this last step. The training objective rewards successful reconstruction of normal inputs, but it says little directly about what should happen to abnormal inputs. There is no explicit penalty for reproducing an anomaly well. As a consequence, good training performance does not establish the desired behavior outside the training distribution.

Shared components make this problem concrete. An unusual image may contain local edges and shapes that also occur in normal images. A decoder that has learned to rebuild those components can sometimes assemble an accurate output even when the overall input should count as abnormal. The authors also point to decoder capacity: a sufficiently capable decoder may reconstruct an unusual encoding without difficulty. Either route weakens the connection between small error and normality.

MemAE changes that connection by placing a restriction between encoding and decoding. The aim is not to stop the encoder from describing an unusual input. Instead, it stops the decoder from receiving that description unchanged. The encoded input must first be expressed through stored representations learned from normal data.

#### Earlier ways of describing normal data

The paper situates its proposal among several approaches to normal-only learning. One-class classification attempts to describe a region containing the normal examples. The cited examples include one-class support vector machines and neural approaches to one-class learning. Their common role in the discussion is to build a discriminative description from examples of only the accepted class.

Clustering and density-based approaches provide another route. The paper mentions k-means and Gaussian mixture approaches as ways to describe the structure of normal observations. A new input can then be evaluated according to its relationship to that description. The authors identify high-dimensional inputs as a difficulty for these conventional methods, especially when observations contain the complexity of video.

Reconstruction methods instead ask whether an input can be represented and rebuilt using structure learned from normal examples. The paper places principal component analysis and sparse representation within this family. Sparse representation methods learn a dictionary alongside restricted combinations of dictionary entries. Their relevance to MemAE is direct: both approaches use a limited collection of learned elements to account for an observation.

The authors nonetheless argue that restricted feature representations limit earlier reconstruction methods. Deep autoencoders offer more adaptable representations, and the cited literature explores several ways of using them. One cited approach uses a structured energy-based network. Another jointly considers encoded features and reconstruction errors. MemAE’s particular intervention concerns the latent route into the decoder: it makes learned normal patterns an explicit intermediate requirement.

This history matters because memory is not presented as an isolated trick. The proposal combines a learned nonlinear representation with a dictionary-like restriction on what can be reconstructed. Its novelty in the paper’s argument is the integration of that restriction into an autoencoder through differentiable, sparse memory access.

#### Why video makes the issue visible

Video surveillance is a motivating application because unusual events can be embedded in otherwise ordinary scenes. The background may remain familiar while a small object or a particular motion pattern changes. A reconstruction system can therefore produce an output that looks broadly successful while failing to expose the event that matters.

The paper describes earlier video approaches that represent motion through optical flow, probabilistic principal components, or dynamic textures. It also discusses sparse coding with multiple dictionaries and an approach that updates a dictionary online. These methods attempt to capture regularity in visual appearance or motion without relying on labeled examples of every possible unusual event.

The deep-learning approaches described in the paper incorporate spatial and temporal structure. Some reconstruct video through convolutional autoencoders. Others use recurrent processing of sparse coefficients or combine reconstruction with prediction. A frame-prediction approach brings together several techniques, including optical flow and adversarial training.

The authors’ criticism is specific: these approaches do not, in their account, provide a sufficiently reliable reason for an anomaly to produce a large reconstruction error. MemAE is intended to add such a reason by controlling the source of the representation used for reconstruction. The resulting comparison is therefore about how a reconstruction signal is produced, rather than simply about using a more elaborate video network.

#### What external memory contributes

The related-work discussion also draws on memory-augmented networks. The paper describes external memory as a way to extend neural computation with stored information that can be accessed through content-based attention. In that setting, an input does not need to identify a fixed address. It can retrieve entries according to their similarity to a query.

Earlier applications discussed by the authors include learning from very few examples and generating data while preserving varied structure. MemAE uses the same broad ability to store and retrieve representations for a different purpose. Its memory is intended to delimit the normal patterns through which reconstruction can proceed.

That distinction is central. The memory is useful not only because it adds storage capacity, but because access to its contents becomes a constraint. The encoder can produce a query for any input, while the decoder must work with the patterns that the normal training process has placed in memory.

### The method, step by step

#### Follow the input through the network

MemAE contains an encoder, a memory module, and a decoder. The encoder transforms the observation into a latent query. The memory module compares that query with stored entries, removes weak access weights, and combines the remaining entries. The decoder reconstructs the observation from that retrieved combination.

Reconstruction through learned normal patterns The steps in order.

During training, the input examples are normal. Reconstruction encourages the entire system to represent them accurately, while sparsity encourages it to do so through concentrated memory access. During testing, the learned memory stays fixed. A new input can select among the stored patterns, but it cannot add a new pattern to accommodate its own unusual structure.

The distinction between a query and a retrieved representation is the main architectural change. In an ordinary autoencoder, the encoder’s output is already the decoder’s input. In MemAE, those are different objects. The query describes what should be searched for; the retrieved representation describes what the memory can supply.

#### Encode the observation

The encoder maps an input from the observation domain into the latent domain:

```
z = fₑ(x; θₑ)
```

Here, x is the input observation, z is its encoded representation, fₑ is the encoder, and θₑ denotes the encoder’s learned parameters. The observation domain contains the inputs appropriate to the application, while the latent domain contains the vectors used for memory queries.

The decoder maps the retrieved latent representation back into the observation domain:

```
x̂ = f_d(ẑ; θ_d)
```

Here, x̂ is the reconstruction, ẑ is the representation supplied by memory, f_d is the decoder, and θ_d denotes its learned parameters. The accent on ẑ distinguishes the retrieved representation from the original encoding z.

For an ordinary autoencoder, these latent representations coincide:

```
ẑ = z
```

The symbols ẑ and z again denote the decoder’s input and the encoder’s output. This equality captures the direct route that MemAE replaces. The memory mechanism is therefore not an additional score attached to an otherwise unchanged reconstruction. It changes the representation from which reconstruction occurs.

The encoder and decoder need not have a particular architecture. The paper uses convolutional layers for images, spatiotemporal convolutions for video, and fully connected layers for cybersecurity vectors. The memory interface remains conceptually the same across those choices.

#### Store a collection of latent patterns

The memory is a matrix:

```
M ∈ ℝ^(N×C)
```

M is the memory, ℝ denotes real-valued entries, N is the number of memory slots, and C is the dimension of each stored vector. Each row mᵢ is a memory entry. For the basic explanation, the query z also has dimension C, so it can be compared directly with every row.

The capacity parameter N determines how many entries can be stored. It does not directly determine how many entries are used for a particular reconstruction. That second question depends on the access weights and their sparsity. Keeping these roles separate helps explain why increasing memory capacity need not remove the restriction imposed by sparse access.

The initial memory-based representation is a weighted combination:

```
ẑ = wM = Σᵢ₌₁ᴺ wᵢmᵢ
```

Here, w is the row vector of access weights, wᵢ is the weight for memory entry mᵢ, and N is the number of entries. The weights are non-negative and sum to one. The matrix product wM and the summation express the same operation: combine the stored vectors according to their weights.

This construction means that the decoder receives a representation assembled from memory, rather than the query itself. However, a dense combination could still be flexible. If many entries contribute, the memory may provide enough compositional freedom to reproduce an unusual input. The later sparsity operations address that possibility.

#### Retrieve by similarity

The access weights depend on how closely each memory entry matches the query. The paper uses a softmax transformation:

```
wᵢ = exp(d(z, mᵢ)) / Σⱼ₌₁ᴺ exp(d(z, mⱼ))
```

The symbol wᵢ is the weight assigned to entry mᵢ. The function d measures similarity between the query z and a memory entry. The function exp is the exponential function, j indexes entries in the denominator, and N is the memory capacity. Dividing by the sum makes the weights add to one.

The chosen similarity is cosine similarity:

```
d(z, mᵢ) = zmᵢᵀ / (‖z‖ ‖mᵢ‖)
```

Here, mᵢᵀ is the transpose of the memory row, so zmᵢᵀ is their dot product. The quantities ‖z‖ and ‖mᵢ‖ are their vector lengths. The division makes the comparison depend on their directional alignment rather than simply rewarding large magnitudes.

This is content-based access. A query does not name a memory address in advance; it produces weights by comparing itself with the stored contents. Similar entries receive stronger weights than dissimilar entries under the softmax transformation.

Nonetheless, softmax alone produces a distribution of positive weights. A relatively weak match can still contribute to the reconstructed representation. The paper’s argument is that many such contributions may collectively allow the system to rebuild an anomaly. Similarity-based retrieval therefore needs an additional restriction if it is to serve the proposed purpose.

#### Remove weak contributions

The intended thresholding rule keeps weights above a threshold and removes the others:

```
ŵᵢ = h(wᵢ; λ) = { wᵢ if wᵢ > λ; 0 otherwise }
```

Here, ŵᵢ is the weight after thresholding, h is the shrinkage operation, wᵢ is the original weight, and λ is the threshold. The value 0 means that the corresponding memory entry contributes nothing to the reconstruction.

This operation is applied to weights, not directly to the stored vectors. The memory may contain many patterns, while each input uses only those receiving sufficiently strong support. The system can therefore retain a varied account of normality without allowing every reconstruction to draw weakly on the whole store.

The authors note that the discontinuity of the thresholding rule complicates differentiation. They use the following expression in the trainable computation:

```
ŵᵢ = max(wᵢ − λ, 0)wᵢ / (|wᵢ − λ| + ε)
```

The symbols ŵᵢ, wᵢ, and λ retain their meanings. The function max selects the larger of its arguments and provides the rectified linear operation. The vertical bars denote absolute value, and ε is a very small positive quantity used in the denominator.

The expression suppresses weights on the low side of the threshold and retains contributions on the high side. Because ε remains present, it is best understood as the paper’s practical differentiable implementation of the intended shrinkage behavior, rather than silently treating it as an exact algebraic identity with the discontinuous rule.

The authors give a practical range for the threshold:

```
λ ∈ [1/N, 3/N]
```

Here, λ is the shrinkage threshold and N is the number of memory entries. This expresses the threshold relative to memory capacity. The paper says that values within this interval produce useful behavior in practice; it does not establish that the interval guarantees successful detection for arbitrary data.

After thresholding, the remaining weights are normalized again:

```
ŵᵢ ← ŵᵢ / ‖ŵ‖₁
```

The symbol ŵ is the vector of thresholded weights, ŵᵢ is one of its entries, and ‖ŵ‖₁ is the sum of its absolute values. Because these weights are non-negative, this normalization makes the surviving contributions sum to one.

The final memory-based representation uses the normalized sparse weights:

```
ẑ = ŵM
```

Here, ẑ is the representation sent to the decoder, ŵ is the normalized sparse access vector, and M is the learned memory. The original dense vector w has now been replaced by the sparse vector ŵ.

This sequence matters operationally. Similarity first determines a preference over memory entries. Thresholding then removes weak contributions. Normalization restores a weighted combination with a consistent total weight. The decoder receives the result of all these operations.

#### Learn memory and reconstruction together

The training objective begins with reconstruction error:

```
R(xᵗ, x̂ᵗ) = ‖xᵗ − x̂ᵗ‖₂²
```

Here, t indexes a training example, xᵗ is that input, x̂ᵗ is its reconstruction, and R is the reconstruction loss. The subscript 2 denotes the Euclidean norm, and the outer square produces the squared reconstruction mismatch.

Minimizing this term encourages accurate reconstruction of the normal training examples. Because the decoder receives memory-derived representations, the pressure to reconstruct also shapes the memory. The entries must become useful building blocks for the normal examples the network repeatedly encounters.

The paper adds an entropy penalty on the normalized access weights:

```
E(ŵᵗ) = Σᵢ₌₁ᵀ −ŵᵢ log(ŵᵢ)
```

Here, E is the entropy penalty, ŵᵗ is the access vector associated with training example t, ŵᵢ is an access weight, and log is the logarithm. There is a notation inconsistency in this displayed expression: T is defined as the number of training examples, whereas the entries being summed are memory-access weights. The surrounding definitions indicate that the entropy concerns the distribution over memory entries.

The intended role of entropy is clear despite that indexing issue. A distribution spread across many entries has more entropy than one concentrated on relatively few entries. Minimizing this quantity therefore encourages concentrated access. Thresholding removes weak contributions directly, while the entropy term influences how the access distribution is learned.

The complete objective combines the reconstruction and entropy terms:

```
L(θₑ, θ_d, M) = (1/T) Σₜ₌₁ᵀ [R(xᵗ, x̂ᵗ) + αE(ŵᵗ)]
```

L is the training objective. The quantities θₑ and θ_d are the encoder and decoder parameters, M is the memory, T is the number of training examples, and t indexes those examples. The function R measures reconstruction mismatch, E penalizes diffuse access, and α controls the contribution of that penalty.

The authors use α=0.0002 across their experiments. They train with [Adam](https://md.research.elamur.ai/free/en/papers/kingma-2014-adam-method-stochastic-optimization/) at a learning rate of 0.0001 and implement the experiments in PyTorch. These settings belong to the reported implementation; the paper does not turn them into requirements for every possible application.

Memory entries are updated through back-propagation along with the network parameters. An entry whose access weight is zero does not receive a non-zero reconstruction-path gradient from that access. Accordingly, the access mechanism affects both the current reconstruction and which stored entries are adjusted by the example.

This gives sparse access a dual role. At training time, it encourages the limited memory to develop useful representatives of normal structure. At test time, it restricts how those representatives can be combined to explain a new observation.

#### Convert reconstruction into an anomaly signal

For a test input, the basic score is the squared reconstruction mismatch:

```
e = ‖x − x̂‖₂²
```

Here, e is the reconstruction error, x is the test observation, and x̂ is the output produced through the fixed learned memory. Larger values indicate a greater mismatch between the input and what the system can reconstruct.

The paper describes this as its mean-square reconstruction criterion, although the displayed expression is a squared Euclidean norm without an explicit division by the number of input coordinates. The important operational point is that the score comes from the discrepancy between the observation and its memory-mediated reconstruction.

For video, the authors turn reconstruction error into a normality score:

```
pᵤ = 1 − (eᵤ − minᵤ(eᵤ)) / (maxᵤ(eᵤ) − minᵤ(eᵤ))
```

The symbol pᵤ is the normality score for frame u, and eᵤ is the reconstruction error associated with that frame. The minimum and maximum are taken over the frames of a video episode. A score nearer 0 indicates a frame regarded as more abnormal.

This normalization reverses the direction of the raw error: larger reconstruction mismatch becomes lower normality. It also makes the score relative to the error range within an episode. That detail matters when interpreting the plotted scores, because they are not direct probabilities that an event is normal.

### Experiments and results

#### What the comparisons are designed to establish

The experiments ask whether memory-mediated reconstruction improves anomaly detection across different input types. The paper tests image outliers, video events, and cybersecurity records. The architectures vary with the observations, while the central memory mechanism remains the same.

The strongest controlled comparisons use an ordinary autoencoder and a memory-equipped version without the sparsity mechanisms. These variants share the encoder and decoder design used by full MemAE. The authors also seek comparable capacity for the variational autoencoder baseline. This makes the comparison more informative than a contest between unrelated architectures with very different reconstruction ability.

The main image and video metric is area under the receiver operating characteristic curve, abbreviated AUC. The curve varies the decision threshold and compares the rate of correctly detected anomalies with the rate of normal examples incorrectly flagged. AUC summarizes ranking behavior across thresholds instead of selecting a particular operating point.

The paper names performance tables for the image, video, cybersecurity, and sparsity comparisons, but the table captions are not accompanied by numerical entries. Exact AUC values and cybersecurity precision, recall, and F₁ values therefore cannot be reported from those tables. The numerical evidence available for a results chart is the running-time comparison. The reported performance rankings can still be described, with that limit kept explicit.

#### Image outliers: learning one class as normal

The image experiments use MNIST and CIFAR-10. Each contains 10 classes. The authors create a separate normal-only learning problem for each class: examples from the selected class count as normal, while examples from the other classes supply anomalies.

Normal examples are divided between training and testing at a rate of 2:1, with no overlap. The anomaly proportion is kept around 30%. The authors also reserve 10% of the original training data for validation. These choices define a controlled one-class experiment, rather than a setting in which the system learns from a mixture containing unknown anomalies.

MNIST is processed as grayscale imagery, while CIFAR-10 retains RGB channels. The former uses a smaller convolutional encoder and decoder. The latter receives a larger architecture because its images contain more varied and complicated content.

For MNIST, the encoder’s convolutional channel counts are 16, 32, and 64. The decoder reverses towards an output with 1 channel. For CIFAR-10, the encoder uses channel counts of 64, 128, 128, and 256, and the decoder returns to 3 output channels. Batch normalization and rectified linear activation follow the intermediate layers. The memory capacities are 100 for MNIST and 500 for CIFAR-10.

The external comparisons include one-class SVM, kernel density estimation, VAE, and PixCNN. DSEBM is another baseline in the image evaluation. Density-based approaches use likelihood-related scores, while reconstruction-based approaches use reconstruction mismatch. For VAE, the authors deliberately calculate the evaluation score from reconstruction error alone.

The authors report that adding memory improves over the ordinary autoencoder and that sparse access improves over unrestricted memory access. They also report stronger results on MNIST than on CIFAR-10 across the compared approaches. Their explanation is that handwritten digits contain relatively simple structure, whereas the natural images have greater content complexity and variation within classes.

This difference is informative. MemAE is not presented as making all normal distributions equally easy to describe. The complexity and variation of the accepted class still affect the quality of the anomaly signal. A memory of normal patterns must cover the normal class adequately before poor reconstruction can serve as convincing evidence of abnormality.

The VAE comparison also receives a qualified interpretation. The authors consider its simple Gaussian latent account adequate for the comparatively simple MNIST setting. MemAE’s advantage is therefore not framed as proof that every alternative latent constraint is ineffective. The image experiments instead support the usefulness of the particular memory restriction under the architectures and scoring choices tested.

#### What the digit reconstructions reveal

The MNIST visualizations make the mechanism easier to inspect than a performance ranking alone. The authors train a memory on images of “9,” select individual entries, and decode them separately. The resulting images are blurry and noisy, but they resemble normal digit patterns.

That observation fits the intended role of memory. An entry is not expected to be a stored copy of a training image, nor is isolated decoding its normal mode of use. Several entries can contribute to a reconstruction. Recognizable structure in an isolated entry nonetheless supports the interpretation that the memory has learned features associated with the accepted class.

A separate example trains on “5” and supplies “9” as the unusual input. MemAE produces a reconstruction resembling “5,” while preserving some similarity in overall shape to the input. This is the desired failure to reproduce: the output reflects the nearest available normal structure instead of faithfully copying the anomaly.

Another visualization uses training examples of “2” and an unusual “4.” The point is again the mismatch between the observed digit and a reconstruction constrained by the learned normal patterns. These cases show how the architecture can enlarge a reconstruction error. They do not establish that every cross-class input will be separated equally well.

The ordinary autoencoder provides the contrast in these visualizations. Its ability to rebuild locally familiar structure can preserve too much of the unusual input. MemAE changes the source of the decoder’s representation, making the output visibly more dependent on the training class.

#### Video: reconstructing spatial and temporal structure

The video evaluation uses UCSD-Ped2, CUHK Avenue, and ShanghaiTech. The paper treats unusual objects and unusual motion as anomalies. Examples include vehicles in pedestrian settings and strenuous activity such as fighting or chasing.

The ShanghaiTech dataset reportedly contains over 270,000 frames for training and over 42,000 for testing, with approximately 17,000 of the test frames classified as abnormal. Its footage spans 13 scenes. These counts establish that the evaluation includes varied scenes rather than only a single repeated view.

To retain temporal information, the network receives a grayscale cuboid formed from 16 neighboring frames. The encoder and decoder use 3D convolutions, allowing the latent representation to depend on both spatial appearance and changes across the clip.

The encoder uses channel counts of 96, 128, 256, and 256. The decoder proceeds through 256, 256, and 128 before producing an output with 1 channel. Intermediate layers use batch normalization and rectified linear activation, following the same broad design convention as the image experiments.

The video memory has capacity N=2000, and each entry has dimension 256. Crucially, memory entries represent features at a spatial position in the encoded feature maps, corresponding to a subregion of the input clip. They do not each represent an entire video cuboid. The resulting memory matrix has dimensions 2000×256.

This local organization changes what counts as a reusable normal pattern. The memory can supply familiar subregion features across different positions or clips, rather than requiring a single entry to cover a whole scene. The basic access operation remains the same, but its unit is a local encoded feature.

At test time, the error for a cuboid centered on a frame determines that frame’s score. The episode-level normalization described earlier produces the displayed normality trace. The authors show examples in which normality falls when an unusual event appears.

The video comparisons include convolutional reconstruction approaches and sparse-coding approaches. StackRNN and the temporal sparse-coding baseline are among the systems discussed. The paper also compares with Frame-Pred, which combines prediction with additional video-specific techniques.

The authors report that MemAE improves over the ordinary autoencoder and the dense-access memory variant. They describe its performance as competitive with the video-specialized approaches, including the frame-prediction approach. They explicitly frame the objective as demonstrating a general improvement to reconstruction-based detection rather than securing the highest accuracy for a particular application.

The error-map visualization provides a more localized observation. In a UCSD-Ped2 example containing unusual objects on a sidewalk, MemAE concentrates error around the abnormal content. The ordinary autoencoder reconstructs that content more successfully and produces less informative errors elsewhere. This supports the proposed mechanism, although the illustrated localization is not a separately quantified localization evaluation.

#### Running time on video

The runtime measurement uses UCSD-Ped2 and an NVIDIA GeForce 1080 Ti. The paper reports average per-frame detection time for MemAE and its ordinary autoencoder baseline.

UCSD-Ped2 average detection time per frame The reported timings place MemAE close to its autoencoder baseline.

**The numbers**

| System or setting | seconds per frame |
| --- | --- |
| AE | 0.0266 |
| MemAE (this paper) | 0.0262 |

The paper also expresses MemAE’s speed as 38 fps. Its broader timing discussion quotes earlier approaches at 0.04s, 0.02s, and 0.05s per frame. Those comparison values come from another paper and were obtained with a faster graphics card, so they are not a controlled hardware-matched ranking.

The narrow result is that the memory mechanism did not produce a large measured runtime penalty in this implementation. The paper’s wording about additional computation does not align cleanly with the ordering of the displayed baseline times. That inconsistency limits a precise interpretation of overhead, while leaving the reported proximity of the timings visible.

#### Cybersecurity: normality follows the experimental designation

The cybersecurity experiment uses the KDDCUP99 10 percent dataset. Each record is represented by a vector with 120 dimensions. This experiment matters because it moves beyond image and video reconstruction to structured numerical inputs.

The class convention requires care. The authors treat the original “attack” category, described as 80% of the data, as normal for the anomaly-detection experiment. Normality therefore refers to the designated training distribution. It does not mean that the original security event was benign.

The encoder reduces the input through dimensions of 60, 30, 10, and 3. The decoder reverses towards the original 120-dimensional representation. Intermediate fully connected layers use Tanh activations. The memory contains 50 entries, each with dimension 3, giving a matrix of size 50×3.

The data are randomly divided so that 50% is assigned to training and the remainder to testing. Only examples of the designated normal class are used for training. Evaluation averages precision, recall, and F₁ over 20 runs.

Precision concerns the reliability of flagged anomalies, while recall concerns how many anomalies are found. F₁ combines those considerations into a single score. Unlike the image and video AUC comparisons, these measures describe decisions at an operating threshold.

The external baselines include OC-SVM, DCN, DSEBM, and DAGMM. The authors report strong performance for both DAGMM and their own approach, attributing MemAE’s result to its explicit representation of the designated normal patterns. Without the numerical table entries, the size of the reported advantage cannot be assessed.

The experiment supports architectural applicability across different input representations. It does not, on its own, establish performance for a deployment that learns only from benign traffic and detects all attacks as anomalies. The training convention is part of the result and must remain attached to its interpretation.

### What the ablations show

#### Adding memory and restricting access answer different questions

The basic architecture comparison separates an ordinary autoencoder from MemAE-nonSpar and full MemAE. The ordinary autoencoder has no memory-mediated route. MemAE-nonSpar adds memory but removes both the shrinkage operation and the entropy penalty. Full MemAE includes memory and both sparsity mechanisms.

The reported ordering supports more than the claim that extra components help. Memory improves the reconstruction-based anomaly signal under the authors’ comparison, and controlling access provides a further benefit. This fits their explanation that a normal-pattern store can still be too flexible when an input may combine many entries.

However, the comparison does not make the learned mechanism fully identifiable. The variants differ in how reconstruction and training interact with memory, and the paper does not provide a complete account of every changed optimization behavior. The defensible conclusion is that the combined design performs better in the reported experiments, with the visualizations offering supporting evidence for the proposed explanation.

The shared encoder and decoder are valuable controls. They reduce the possibility that the result merely reflects a more suitable image or video architecture. They also keep attention on the latent interface, which is the paper’s intended contribution.

#### Shrinkage controls access during evaluation

The targeted sparsity ablations use UCSD-Ped2. One variant removes the thresholding operation while retaining the entropy-based training incentive. The authors report degraded AUC relative to full MemAE.

Their explanation concerns the difference between a training preference and an evaluation-time restriction. Entropy minimization can encourage concentration during learning, but it does not directly remove weak contributions when a new input is evaluated. Thresholding performs that removal as part of the forward computation.

This distinction is important for anomaly detection because unusual inputs may produce access distributions unlike those usually encountered during training. A concentrated distribution on normal examples does not guarantee concentrated access on every abnormal example. The shrinkage operation acts on the current weights regardless of why those weights arose.

The ablation therefore supports the practical value of imposing sparsity in the actual reconstruction path. It does not show that the chosen threshold is universally optimal, nor does it measure every possible alternative method for sparse retrieval.

#### Entropy helps shape the learned access behavior

Another variant removes the entropy penalty while retaining shrinkage. This also performs worse than full MemAE in the reported UCSD-Ped2 comparison. The authors emphasize the early part of learning, when access weights have not yet become well adapted to the training data.

A threshold can suppress small contributions, but it does not on its own provide the same incentive to organize the pre-threshold distribution. Entropy minimization encourages the system to form clearer preferences among entries. That can affect which entries are selected and how those entries develop as training proceeds.

The paper’s account therefore assigns different jobs to the sparsity components. Shrinkage directly restricts the representation used for reconstruction. Entropy influences the training dynamics that produce the access distribution. Their benefits can be complementary even though both are described as encouraging sparse access.

The experiment supports that complementarity in the tested setting. It does not independently trace the full training dynamics or demonstrate that early-stage entropy is the only reason for the improvement. That explanation should be understood as the authors’ interpretation of the controlled comparison.

#### Sparse latent activations do not reproduce the whole effect

The authors also test an ordinary autoencoder with a sparsity penalty on its encoded features. The additional quantity minimized is:

```
‖z‖₁
```

Here, z is the encoder output, and ‖z‖₁ is the sum of the absolute values of its components. Reducing this quantity encourages a sparse latent representation. The corresponding baseline is called AE-ℓ₁.

This is a useful challenge to the paper’s explanation. If almost any sparsity penalty delivered the same gain, a memory of normal patterns might be unnecessary. AE-ℓ₁ tests whether the benefit could instead arise mainly from making the encoder’s activations sparse.

The authors report that AE-ℓ₁ improves over the ordinary autoencoder and performs near MemAE-nonSpar. It remains below full MemAE and the other memory variants discussed in this ablation. Thus sparse latent activations help, but they do not reproduce the complete effect of memory-mediated reconstruction.

The architectural distinction explains the relevance of this result. Sparse encoder output still reaches the decoder directly. Sparse memory access instead requires the decoder’s representation to be assembled from learned entries. The latter restricts the available building blocks, not merely the number of active coordinates in the query.

#### Capacity and visualization provide supporting analyses

The memory-size analysis varies capacity on UCSD-Ped2. The authors report stable behavior once the memory is sufficiently large. This supports their practical claim that finding a single exact capacity is not necessary for that dataset.

No numerical values from the plotted capacity sweep are stated in the text, so it does not support a precise capacity recommendation beyond the reported experimental setting. It also does not establish the same robustness for every application.

The decoded memory entries and reconstruction maps provide a different kind of evidence. They help connect the observed performance ordering to the intended behavior: normal-looking stored patterns, reconstructions pulled toward the normal class, and errors concentrated around unusual content. These analyses strengthen the interpretation without replacing quantitative comparisons.

### Limitations

#### What the authors explicitly leave open

The authors describe a general architectural improvement, instead of a complete solution for every anomaly-detection application. They explicitly place the pursuit of the highest application-specific accuracy outside the main purpose of their video experiment. Their argument is that memory can strengthen reconstruction-based detection and can potentially be combined with other techniques.

They also identify future work around the access weights themselves. The reported detector uses reconstruction error as its decision signal. Although the memory weights are central to generating that error, the paper does not establish a separate anomaly detector based directly on those weights.

Another stated direction is integration with more elaborate encoder-decoder systems and application to harder problems. The fact that the memory interface does not require one particular architecture makes such integration plausible. It does not establish that every more complicated base system would benefit.

The authors also acknowledge that choosing an optimal memory capacity for different datasets is not straightforward. Their capacity analysis offers practical reassurance for UCSD-Ped2 once the memory is large enough. It does not eliminate capacity selection as a design question.

#### Normal training data define the meaning of the result

A limitation visible in the setup is the dependence on normal-only training. The method learns its account of normality from the examples it receives. The experiments do not establish robustness when the training set contains an unknown amount of anomalous material.

This matters especially because memory is learned jointly with reconstruction. If unwanted patterns appear in training and help reduce reconstruction loss, the architecture has no independent semantic rule identifying them as unwanted. The paper’s central argument assumes that the memory is being shaped by the intended normal distribution.

The cybersecurity experiment makes the operational nature of normality particularly clear. A category originally called “attack” becomes the accepted training category. The detector’s task is therefore defined by the experiment’s class assignment. It would be misleading to reinterpret the result as automatic recognition of benign behavior without keeping that assignment in view.

The same caution applies to image classes. An image can be unusual relative to a chosen training class without being intrinsically abnormal. The experiments test distributional departure under a controlled designation, not a universal concept of abnormality.

#### Memory restriction is an incentive, not a guarantee

The proposed architecture gives a reason for anomalies to reconstruct poorly, but it does not prove that they must do so. An unusual input may still resemble a small combination of normal patterns. Its encoder output may retrieve entries that allow an accurate reconstruction, or the decoder may map a retrieved combination to something close to the anomaly.

Conversely, a legitimate normal example may be reconstructed poorly if its variation is inadequately covered by the learned memory. The method must balance coverage of normal diversity against restriction of abnormal reconstruction. The paper’s reported image difficulty on CIFAR-10 is consistent with this broader dependence on the complexity of the normal distribution.

The visualized memory entries do not settle this balance. Recognizable normal structure in a few decoded entries supports the intended interpretation, but does not prove that every entry has a distinct role or that the collection covers all relevant normal cases.

Similarly, a reconstruction error map is evidence of mismatch instead of a full causal explanation. Highlighting an unusual object in an example shows useful behavior. It does not establish that all high-error regions correspond to meaningful anomalies or that every abnormal event will be localized.

#### Evaluation leaves deployment questions unanswered

The reported AUC evaluations assess ranking across thresholds. They do not by themselves specify which threshold should be chosen for a deployed detector, how many false alarms a user would tolerate, or how that threshold would behave under changing conditions.

The video normality score also uses the minimum and maximum error within an episode. It is therefore relative to the other errors in that episode. The paper does not establish that these normalized values are calibrated across episodes or can be interpreted as absolute probabilities.

Because the normalization uses an episode’s error range, the stated scoring procedure is not itself a complete prescription for decisions made before that range is available. The runtime measurement demonstrates computational speed for frame processing; it does not resolve every issue involved in producing an immediate operational score.

The image protocol fixes an anomaly proportion around 30% and defines anomalies through other known classes. That is useful for controlled comparison, but the experiments do not establish the same behavior under every possible anomaly prevalence or type of departure.

The cybersecurity precision, recall, and F₁ measurements answer different questions from AUC, but their exact numerical entries are unavailable alongside the named table. This prevents assessment of the size and balance of the reported gains. The qualitative conclusion should therefore remain narrower than a claim of a quantified universal advantage.

#### Numerical and implementation details need care

The timing discussion contains an internal inconsistency. The reported per-frame value for MemAE is lower than the stated value for the autoencoder baseline, yet the prose describes a small additional computation cost. The appropriate conclusion is that the measured times are close. The text does not support a clean numerical account of added latency.

Timing comparisons with earlier systems are also limited by hardware differences and by the use of values quoted from another work. They offer context, not a controlled speed benchmark. No conclusion about all implementations or devices follows from that comparison.

The entropy equation has an indexing inconsistency: its upper summation limit uses the training-set symbol even though the entries belong to the memory-access distribution. The intended entropy regularizer is understandable from the definitions, but the displayed notation should not be copied into an implementation without resolving that mismatch.

The normalization after shrinkage also presumes that some positive access weight remains. The paper states a practical threshold interval but does not discuss a fallback for a completely removed distribution. This is an implementation question visible from the equations, rather than an experimentally documented failure.

Finally, the paper’s cross-domain experiments support flexibility of the memory interface. They do not establish language understanding, factual verification, or reliable linguistic anomaly detection. Any transfer to Mova would need a new definition of the reconstruction target and new evidence that the resulting mismatch measures something useful.

### What came after

The later influence of MemAE cannot be traced to named follow-up studies on the evidence available here. That is not a claim that no later work exists. It means there is no substantiated sequence of subsequent papers to describe, and no basis for assigning particular later results to this method.

The paper itself points toward several continuations. One is to investigate the access weights as an anomaly signal in their own right. The reported method uses those weights to construct a restricted representation, then evaluates the final reconstruction. Studying the weights directly would ask whether retrieval behavior contains useful evidence beyond the mismatch visible at the output.

Another proposed continuation is integration with more elaborate reconstruction systems. Because the memory operates between encoder and decoder, it can be considered separately from the detailed architecture used to encode observations or generate reconstructions. The authors also discuss possible combination with video-specific techniques such as prediction and motion information. Those combinations remain proposals in this paper, not reported improvements.

The durable research question is how to make a detector’s failure behavior useful. Training an autoencoder only to reconstruct normal inputs leaves its behavior on anomalies underdetermined. MemAE responds by limiting the representations through which reconstruction must pass. Its experiments and ablations support that response under the tested conditions, while leaving open how best to define normal patterns, control their combinations, and interpret reconstruction failure in other domains.

## Cite

Cite as Dong Gong, Lingqiao Liu, Vuong Le, Budhaditya Saha, Moussa Reda Mansour, Svetha Venkatesh and Anton van den Hengel. 2019. Memorizing Normality to Detect Anomaly: Memory-Augmented Deep Autoencoder for Unsupervised Anomaly Detection. IEEE/CVF International Conference on Computer Vision (ICCV).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1109/iccv.2019.00179](https://doi.org/10.1109/iccv.2019.00179) · [arXiv 1904.02639](https://arxiv.org/abs/1904.02639)

```bibtex
@inproceedings{gong2019memorizing,
  title = {{Memorizing Normality to Detect Anomaly: Memory-Augmented Deep Autoencoder for Unsupervised Anomaly Detection}},
  author = {Dong Gong, Lingqiao Liu, Vuong Le, Budhaditya Saha, Moussa Reda Mansour, Svetha Venkatesh and Anton {van den Hengel}},
  booktitle = {IEEE/CVF International Conference on Computer Vision (ICCV)},
  year = {2019},
  doi = {10.1109/iccv.2019.00179},
  eprint = {1904.02639},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1109/iccv.2019.00179}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
