Dual Memory Units with Uncertainty Regulation for Weakly Supervised Video Anomaly Detection
- Publication
- AAAI 2023Conference
- First submitted to arXiv
- arXiv:2302.05160
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{anomalydetectionurdmu2023,
title = {{Dual Memory Units with Uncertainty Regulation for Weakly Supervised Video Anomaly Detection}},
author = {Hang Zhou and Junqing Yu and Wei Yang},
year = {2023},
eprint = {2302.05160},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2302.05160}
}
Since UCF-Crime, weakly supervised video anomaly detection has had a fixed skeleton. Each video is cut into many segments and features are extracted with a pretrained model; training only knows whether something happened somewhere in the whole video, so the top-scoring few segments are compared against the video label.
Most of the improvements in the years that followed went into the anomaly side. RTFM found that anomalous segments usually have larger feature norms and used the norm to pick suspicious segments; MIST first generates pseudo-labels with MIL and then turns around and trains itself on them; MSL switched to a Transformer and took the same self-training route.
Hang Zhou, Junqing Yu and Wei Yang of Huazhong University of Science and Technology felt this left out half the picture. To tell what's anomalous, you first have to know what's normal. Learning only what anomalies look like leads to false alarms on hard-to-call segments. Running, for example, is normal in a sports video and part of the anomaly in footage of a police chase.
Defining the problem

The authors set out to solve two things.
First, there's actually plenty of normal data. Half the training set is videos that are normal from start to finish, and most of an anomalous video is normal segments too. Earlier methods treated these segments as background that should "score low" and rarely modeled them.
Second, normal footage is noisy in itself. When the camera cuts, the people in the frame change or the scene shifts, the features jump. If the model memorizes only a few fixed normal appearances, these jumps may be taken for anomalies.
So the authors want a model that memorizes the typical appearance of normal and anomalous footage separately and, on the normal side, memorizes a distribution with some width rather than just a few points.
Solving the problem

The input follows convention. One RGB feature is extracted every 16 frames with an I3D pretrained on Kinetics-400; for UCF-Crime the authors use the 10-crop features released by earlier work, and during training each video is cut into 200 segments.
The model has three parts. GL-MHSA handles temporal relations, the dual memory units memorize the typical appearance of normal and anomalous footage, and NUL turns normal features into a distribution.
GL-MHSA
The authors borrow the "global plus local" structure from graph convolutional networks and open an extra local branch beside multi-head self-attention. The global branch is ordinary self-attention; the local branch projects a separate set of values and weights them with a mask that decays with temporal distance:
After a softmax, the mask is multiplied by , and the result is concatenated with the output of the global branch.
In the official code, the local branch's weights are fixed. They depend only on how many segments apart two segments are, not on what's in the frames, and is fixed at 1 too. In other words, this branch acts much like an exponentially decaying temporal smoothing that mixes information from a few neighboring segments into each one.
Two memories

The anomaly memory and the normal memory are each 60 learnable 512-dimensional vectors. Each segment feature queries a memory to get similarity scores, and the scores weight the memory for the readout:
For each segment, the top similarities to the memory are averaged into a score for how much that segment "looks like this memory."
During training, four binary cross-entropy terms constrain these scores. Every segment of a normal video must look like the normal memory and unlike the anomaly memory. Anomalous videos follow MIL logic, which only requires some of their segments to look like the anomaly memory and some to look unlike the normal memory, not every segment.
Next comes a triplet loss. The anchor is the few segments of normal videos that look most like the normal memory, the positive is the few segments of anomalous videos that look most like the normal memory, and the negative is the few segments of anomalous videos that look most like the anomaly memory. The normal segments inside anomalous videos are pulled toward normal videos, and the anomalous segments are pushed away.
Turning normal into a distribution
The features read out of the normal memory then pass through two encoders that predict a mean and a variance respectively, sampled with the reparameterization trick:
A KL divergence term then pulls this distribution toward a standard normal, keeping from growing so large that samples land far from the real features. The approach comes from data uncertainty learning in face recognition.
The anomaly side gets no distributional assumption and goes only through the mean encoder. Finally, feature norms pull the two apart, with an anomalous segment's required to exceed a normal segment's by at least . This carries on RTFM's observation that anomalous features have larger norms.
At test time there's no sampling; only the mean is used.
Still MIL in the end
The original features and the features read out of the two memories are concatenated and fed into a small MLP that outputs an anomaly score for each segment. During training, a video's score is the average of its top segment scores, compared with the video label through binary cross-entropy. UCF-Crime's recipe of "compare the most suspicious few segments" is still the main loss here.
The learning rate is and the batch size 64, with 3000 training iterations.
Discussion
Main results
UCF-Crime uses frame-level AUC, and XD-Violence frame-level AP.
| Method | Features | UCF-Crime AUC |
|---|---|---|
| Sultani et al. | I3D | 76.21 |
| HL-Net | I3D | 82.44 |
| RTFM | I3D | 84.30 |
| MSL | I3D | 85.30 |
| MSL | VideoSwin | 85.62 |
| UR-DMU | I3D | 86.97 |
The paper reports a 1.35-point lead over MSL, the previous best, but that comparison is with the version of MSL that uses VideoSwin features. With I3D on both sides, the gap is 1.67.
On XD-Violence, RGB alone gives 81.66 AP and concatenating audio features gives 81.77, about 4 points above RTFM's 77.81 and on par with multimodal methods that need audio.
Ablations
The module ablation is the most thorough, and its table adds two kinds of numbers. AUCsub and APsub are computed only on anomalous videos, showing how accurately the model localizes within them; FAR is computed only on normal videos, showing false alarms.
| Modules | AUC | AUCsub | FAR |
|---|---|---|---|
| GL-MHSA | 82.89 | 60.18 | 4.86 |
| + DMU | 85.53 | 70.13 | 1.53 |
| + NUL | 85.19 | 69.74 | 2.37 |
| All | 86.97 | 70.81 | 1.05 |
With only GL-MHSA, the false alarm rate on normal videos is 4.86%. Adding the dual memory units brings it down to 1.53%, and the AUC within anomalous videos jumps from 60 to 70; this is the step with the largest effect.
The memory unit ablation has a small twist. With only the anomaly memory, UCF-Crime AUC is 83.72; with only the normal memory, 85.19; with both, 86.97, which agrees with the paper's claim. In false alarm rate, however, the normal memory alone gives 0.98% on UCF-Crime and 0.48% on XD-Violence, while using both gives 1.05% and 0.65%. The paper's starting point is to reduce false alarms with dual memories, and in this table the lowest false alarm rate belongs to the normal memory alone.
The number of memory slots was also swept from 20 to 100. AUC bounces between 85.09 and 86.97 with no clear trend, and the 60 the paper uses is the highest point in the table; the false alarm rate swings between 0.49% and 2.01%. Changing the number of memory slots alone moves AUC by nearly 2 points, so the 1.35-point lead in the main results deserves some discount against that range.
On the loss side, removing any one of the memory constraint, triplet or KL terms among the four auxiliary losses drops UCF-Crime AUC by 3 to 5 points; the norm-distance loss is the exception, costing only 0.37 when removed.
Reproduction
The official code is public, and the README even includes a "best performance" checkpoint.
Retraining with the official code, people in the issues report UCF-Crime AUCs around 85.7, a little over a point below the paper; one person found that a somewhat larger batch helps. Those who extracted I3D features themselves fared worse, reporting AUCs of 0.78 in one case and 0.68 in another. That issue has been open since February 2023; at the time the authors said they were busy and would upload their own extracted features in a few days, and nothing more was heard (a few days that have now stretched past a thousand). The repository's most recent update, in January 2025, changed the citation format in the README.
Someone asked how the false alarm rate in the ablation tables is computed, since the repository has no code for it. The authors replied that you just count the outputs over all normal videos, and added "I believe you can complete this simple task." Another user found that the annotation file used for evaluation didn't match the length of their own extracted features and was advised to rebuild it themselves; in the end, yet another user wrote a script to rebuild it.
To be fair, when someone pointed out a wrong index in the norm-distance loss, the authors acknowledged it and fixed it within two days.
Conclusion
UR-DMU's argument is intuitive. To tell what's anomalous, first get a firm grip on what's normal. Two memories learn what normal and anomalous footage look like, and on the normal side a Gaussian distribution absorbs the noise.
The method stacks up quite a lot, with five losses, two memories and a distributional assumption, and the final video score is still the MIL recipe. In the ablations, what really opens the gap is the dual memory units, while the false alarm rate the paper cares about most is actually lower with the normal memory alone.
If you plan to extract your own features and rerun it, read through those 0.68 and 0.78 reports in the issues before you start.