Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

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

Memory-augmented autoencoders stop reconstructing anomalies, so anomalies stand out more

  • Problem Autoencoders trained on normal data are expected to reconstruct anomalies poorly, but they often generalize so well that they also rebuild anomalies, hiding them. This makes reconstruction error an unreliable detection signal.
  • Method MemAE adds a memory of normal prototypes between the encoder and decoder. The encoding queries the memory, and the decoder rebuilds the input only from retrieved memory items, using sparse addressing with hard shrinkage and an entropy loss.
  • Results MemAE reached an AUC of 0.9751 on one-class MNIST, against 0.9619 for the plain autoencoder. It also reached 0.941 on UCSD-Ped2.

Why reconstruction error can mislead

The usual recipe trains an autoencoder on normal data only and treats a high reconstruction error on a test input as a sign that the input is abnormal. This rests on the expectation that normal inputs, being close to the training data, are rebuilt more faithfully than abnormal ones.

The expectation does not always hold. An encoder and decoder that generalize well can rebuild inputs they never saw during training, including anomalies. Anomalies that share local structure with normal data, or a decoder that is too capable, can both lead to good reconstructions of abnormal inputs. The authors observe this behaviour in their own experiments as well as in earlier work.

Memory as a bank of normal prototypes

MemAE does not pass the encoding straight to the decoder. The encoding is used as a query against a memory, and the decoder receives a combination of the memory items that the query retrieves. The encoder therefore acts as a query generator, and the decoder only sees content drawn from what the memory holds.

The memory is a matrix \(M\in\mathbb{R}^{N\times C}\) with \(N\) rows, each a memory item \(m_i\) of dimension \(C\) that matches the encoding. For a query \(z\), the addressing weights come from a softmax over cosine similarities, \(w_i=\frac{\exp(d(z,m_i))}{\sum_{j=1}^{N}\exp(d(z,m_j))}\), with \(d(z,m_i)=\frac{z\,m_i^{T}}{\|z\|\,\|m_i\|}\).

The readout is the weighted sum \(\hat z = wM=\sum_{i=1}^{N} w_i m_i\), and the decoder reconstructs \(\hat x\) from \(\hat z\).

The reason for this design is the bottleneck on what the decoder can produce. When each reconstruction must come from a few stored normal items, the decoder cannot easily build an abnormal input from its own detail. Training fills the memory with the most representative normal patterns, so reconstructions tend to look normal even when the input does not.

Setting \(\hat z = z\) recovers the standard autoencoder, so the memory is the only difference between the two models.

Keeping the addressing sparse

A dense weight vector can still combine many small contributions into a close reconstruction of an anomaly, so sparsity is enforced on the weights. The hard shrinkage operator sets each weight to zero unless it exceeds a threshold \(\lambda\), and the surviving weights are renormalized with the \(\ell_1\) norm. The threshold is set in the interval \([1/N, 3/N]\), which the authors report gives desirable results.

The discontinuous cut has no useful gradient, so the authors replace it with a ReLU-based form, \(\hat w_i=\frac{\max(w_i-\lambda,0)\,w_i}{|w_i-\lambda|+\epsilon}\), where \(\epsilon\) is a very small positive scalar. This keeps the operation differentiable, so the memory and the encoder can be trained through it.

A second sparsity term is an entropy loss on the addressing weights, \(E(\hat w)=-\sum_i \hat w_i\log \hat w_i\), which is added to the reconstruction loss. The authors also note that the sparse addressing gives the sparse weights in one forward pass, where sparse coding methods need iterative updates.

Training and scoring at test time

During training the encoder, the decoder and the memory contents are all updated by backpropagation to lower the combined loss. Only memory items with non-zero addressing weights receive gradients in a given pass. Training uses the Adam optimizer with a learning rate of 0.0001 for MemAE and its variants.

At test time the memory is fixed. The reconstruction is built from the normal items that lie closest to the encoding of the test input. The anomaly criterion is the squared l2 reconstruction error \(e=\|x-\hat x\|_2^2\) on the test input.

For video, the reconstruction error of a cuboid is assigned to its centre frame, and the errors are normalized to the range [0, 1]. The per-frame normality score is \(p_u = 1-\frac{e_u-\min_u e_u}{\max_u e_u-\min_u e_u}\), so values near 0 indicate frames that are more likely abnormal.

One-class results on MNIST and CIFAR-10

Each dataset yields 10 one-class problems: one class is normal and the rest are anomalies, with about 30% anomalies in the test set. Normal samples are split 2:1 into training and test sets, and 10% of the original training data is kept for validation. The MNIST encoder uses three convolutional layers, and the CIFAR-10 model uses wider layers, with memory sizes of 100 for MNIST and 500 for CIFAR-10.

Baselines include OC-SVM, KDE, a variational autoencoder, PixCNN and DSEBM, plus the plain AE and MemAE-nonSpar, all given similar model capacity. Performance is the AUC averaged over the 10 sampled datasets.

On MNIST, MemAE reached 0.9751 and MemAE-nonSpar 0.9725, against 0.9619 for the plain AE. The variational autoencoder reached 0.9643 on MNIST, close to the AE, and the authors attribute its strength to the simple digit structure. KDE reached 0.8116 and PixCNN 0.6141 on MNIST.

On CIFAR-10 every method scores lower than on MNIST. MemAE reached 0.6088, MemAE-nonSpar 0.6058 and the plain AE 0.5706. The authors attribute the drop to the more complex content of CIFAR-10 and the larger intra-class variance in several classes.

What the memory slots store on MNIST

The memory was trained on digit 9 treated as normal, and a single randomly chosen slot was decoded on its own. The decoded slot is blurry and noisy, because reconstructions normally combine several addressed items. Even so, different slots capture different prototypical versions of the digit 9.

In the example trained on the digit 5, an input of digit 9 is reconstructed as a 5 with a shape similar to the input. The authors explain that the memory returns the most similar normal patterns, so the abnormal digit does not pass through unchanged. The plain AE tends to learn representations more locally, so it can rebuild an abnormal sample well.

Video anomaly detection on three benchmarks

Experiments use UCSD-Ped2, CUHK Avenue and ShanghaiTech. ShanghaiTech has more than 270,000 training frames and more than 42,000 test frames, of which about 17,000 are abnormal, across 13 scenes. The encoder and decoder use 3D convolutions over a cuboid of 16 stacked grayscale frames. Each memory slot holds the features of one spatial position in the feature map, and the memory has \(N=2000\) items of dimension 256.

On UCSD-Ped2, MemAE reached 0.941 against 0.917 for the AE and 0.929 for MemAE-nonSpar. On CUHK Avenue it reached 0.833 against 0.810 for the AE, and on ShanghaiTech 0.712 against 0.697. Frame-Pred scored higher than MemAE on all three, with 0.954, 0.849 and 0.728, and it uses optical flow and adversarial training. The authors describe MemAE as comparable to that method, and note that their aim is a general reconstruction model rather than the highest score in one application.

On an abnormal UCSD-Ped2 frame, the MemAE error map highlights the moving vehicle and bicycle on the sidewalk, while the AE reconstructs them and produces scattered errors.

MemAE processes one UCSD-Ped2 frame in 0.0262 seconds, about 38 fps, on an NVIDIA GeForce 1080 Ti. The timings of other methods are quoted from the work that proposed them and were measured on a faster graphics card than the one used here.

A memory size study on UCSD-Ped2 varies \(N\) from 500 to 3000. Once the memory is large enough, the authors report that MemAE gives plausible results robustly.

KDDCUP cybersecurity results

The data is KDDCUP99 10 percent from the UCI repository, with 80% of the samples labelled attack treated as normal. Each sample is a 120-dimensional vector, encoded and decoded by fully connected layers, with a memory of \(N=50\) items of size 3. Half of the data is used for training and the rest for testing, and results are averaged over 20 runs with precision, recall and F1.

MemAE reached an F1 of 0.9641, with precision 0.9627 and recall 0.9655. The plain AE reached an F1 of 0.9342, and DAGMM 0.9369. The authors attribute the gain to the memory explicitly storing behaviour patterns of the attack samples.

Which sparsity components matter

The two sparsity components are the hard shrinkage and the entropy loss, and each is removed in turn while the other stays in place. Removing either component lowers the score, so each contributes to this result.

The authors explain that without shrinkage the model cannot directly encourage sparsity at test time, which can leave noisy, dense weights. They attribute the value of the entropy loss to the early stage of training, when the addressing weights are still poorly optimized.

The authors argue that this penalty lacks the memory mechanism that pushes reconstruction errors up on anomalies, which explains why it stays below MemAE.

Limits of the evidence

The video comparison is not a matched test against the strongest methods, since Frame-Pred uses optical flow and adversarial training that MemAE does not. The authors state that their study is orthogonal to that line of work and could be combined with it.

CIFAR-10 remains hard, with MemAE at 0.6088 AUC on average. The memory-size robustness and the sparsity ablation are measured only on UCSD-Ped2. Memory sizes are chosen per dataset: 100 for MNIST, 500 for CIFAR-10, 2000 for the video data and 50 for KDDCUP.

Running time comparisons with other methods rely on timings from another source on a faster card. The authors leave open whether the addressing weights themselves can be used for anomaly detection.

Paper info

Authors
Dong Gong, Lingqiao Liu, Vuong Le, Budhaditya Saha, Moussa Reda Mansour, Svetha Venkatesh, Anton van den Hengel
Venue
arXiv · Preprint
First published
2019-4-4
Added
2026-11-12
Updated
2019-8-6
Version
v2
arXiv
1904.02639
Category
cs.CV
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Dong Gong, Lingqiao Liu, Vuong Le, Budhaditya Saha, Moussa Reda Mansour, Svetha Venkatesh, Anton van den Hengel (2019). Memorizing Normality to Detect Anomaly: Memory-augmented Deep Autoencoder for Unsupervised Anomaly Detection. arXiv:1904.02639v2. https://arxiv.org/abs/1904.02639v2

BibTeX
@misc{gong2019memorizing,
  title = {{Memorizing Normality to Detect Anomaly: Memory-augmented Deep Autoencoder for Unsupervised Anomaly Detection}},
  author = {Dong Gong and Lingqiao Liu and Vuong Le and Budhaditya Saha and Moussa Reda Mansour and Svetha Venkatesh and Anton van den Hengel},
  year = {2019},
  eprint = {1904.02639},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.02639v2}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up