Every security system in the world is built on the same basic assumption: if you know what normal looks like, you can recognise what isn't. A heartbeat that falls outside the usual rhythm. A network packet that doesn't match the pattern of legitimate traffic. A chemical compound that no one has seen before. In each case, the problem isn't finding the needle. It's knowing enough about the haystack.
Machine learning researchers call this anomaly detection, and it's one of the quieter but more consequential problems in the field. The methods that work well for images, those slick algorithms that can spot a defective component on a production line, don't transfer cleanly to a hospital spreadsheet or a social media graph. Every type of data seems to need its own rules, its own intuitions about what transformations preserve meaning and which ones make something unrecognisable.
A paper published in IEEE Transactions on Pattern Analysis and Machine Intelligence argues that we've been approaching this the wrong way. Instead of designing rules for each data type by hand, the system should learn them from the data itself.
The Problem With Hand Crafted Rules
The standard approach to self supervised anomaly detection borrows a clever idea from image processing. You take a photo of a dog, rotate it 90 degrees, and then train a model to predict which rotation was applied. After training, the model has learned something about what dogs look like from every angle. When you show it something that isn't a dog, it struggles to predict the rotation correctly, and that failure becomes your signal that something is off.
The technique works beautifully on images because the transformations are obvious. Humans know that dogs are still dogs when you flip them upside down. That intuition is easy to encode. But what does it mean to rotate a table of patient records? How do you flip a sentence from a financial earnings report? What's the equivalent of a 90 degree rotation in a network graph representing criminal transactions?
There isn't an obvious answer, and every attempt to find one requires a researcher to sit down with domain knowledge and design something specific. That's expensive, slow, and doesn't generalise. A method that works on epilepsy monitoring data might be useless for detecting fake reviews.
The new system, called NeuTraL AD, for Neural Transformation Learning for Anomaly Detection, sidesteps this problem by learning the transformations directly from the data.
Teaching a Machine to See Differently
The core idea is elegant enough to explain without the mathematics.
Imagine you want to teach someone to spot a forgery in a collection of paintings. You could give them a list of rules: check the brushstroke direction, look at the chemical composition of the pigments, examine the canvas texture. Or you could have them spend time with authentic paintings until they develop their own intuitions about what makes something genuine.
NeuTraL AD does something like the second approach. It takes each sample in the training data and runs it through a set of learned transformations, producing multiple different views of the same item. These aren't rotations or flips. They're abstract mathematical operations whose parameters are adjusted during training to satisfy two competing goals at once.
First, each transformed view should stay close in meaning to the original. A transformed version of an epilepsy signal should still look like an epilepsy signal, not like random noise. Second, the different transformed views should be as distinct from each other as possible. If all your transformations produce identical output, you've learned nothing useful.
The loss function the team designed, which they call the Deterministic Contrastive Loss, balances these two pressures against each other. Pull the transformed versions toward the original, push them away from each other. The resulting transformations learn to highlight different aspects of the data, in the same way that different lighting conditions reveal different features of a physical object.
Why This Matters for Scoring Anomalies
Here's where the approach becomes particularly clever. The same mathematical function used to train the system is also used to score new data at test time.
During training, the transformations get better at producing consistent, well organised views of normal samples. The different versions cluster neatly. They're distinct from each other but all recognisably related to the original. The loss function, which measures how well this structure holds together, ends up being very low for normal data.
When an anomalous sample arrives, something different happens. The learned transformations were designed around the patterns in normal data. They don't know how to produce coherent views of something that doesn't fit those patterns. The views become incoherent. The structure breaks down. The loss function, now used as an anomaly score, ends up high.
This is different from most contrastive learning approaches, which need to compare a sample against other samples in the batch to compute a score. That creates a problem at test time: you're comparing a new anomaly against whatever other data happens to be nearby, which introduces noise and bias. NeuTraL AD scores each sample in isolation, comparing only the different views of that single item against each other. No batch dependency. No bias from what else happens to be in the room.
What the System Actually Learned
One of the more satisfying moments in the paper comes from visualising what the system taught itself.
For audio data, specifically recordings of spoken Arabic digits, the researchers could visualise the learned transformations as heat maps overlaid on the frequency content of each recording. The system had discovered that different frequency bands carry different information. One transformation focused attention on certain pitch ranges. Another zeroed out entire frequency bands almost completely. A third highlighted content in the middle of the recording but ignored the beginning and end.
Nobody told it to do this. It found these structures because they turned out to be the most useful way to produce distinct but meaningful views of the audio. The system reverse engineered something like a music analyst's toolkit, just from examples of normal speech.
For images, the team could go further. They took the transformed feature representations and inverted them back into image space, producing pictures of what the transformations were doing. The results showed that the system had learned to disrupt different local regions and textures of each image while preserving the overall shape and identity of the object. A car was still recognisably a car. A horse was still a horse. But each transformed version had a slightly different texture, a slightly different emphasis on local detail.
They verified this wasn't just appearance. A separate classifier trained to recognise objects from features gave the same label to transformed and original versions, confirming the system had preserved semantic content even while creating visually distinct views.
The Numbers Across Five Domains
The researchers tested NeuTraL AD against a comprehensive set of competitors across five very different types of data.
For time series, covering audio, motion signals, and medical recordings, the system raised detection accuracy by 7.2 percentage points on average compared to the next best method. On epilepsy data specifically, it pushed the standard benchmark from an AUC of 82.6% to 92.6%, a ten point improvement that in a clinical setting could translate to many fewer missed seizures.
For tabular data, the kind that fills hospital records and cyber intrusion logs, it outperformed every baseline on every dataset tested. On an arrhythmia detection task, it raised the F1 score by 3.7 percentage points compared to the previous best approach, using just eleven learned transformations where competing methods needed 256 random ones to achieve worse results.
For text, working on top of word embeddings from a pretrained language model, it achieved the best detection accuracy on six of seven test variants on the Reuters dataset, improving over the state of the art by 1.3 percentage points on average.
For graphs, the improvements were most dramatic. Across six datasets spanning biological networks, molecular data, and social networks, NeuTraL AD raised detection accuracy by 7.5 percentage points on average. More striking than the raw numbers: every competing method suffered from what researchers call performance flip, meaning it sometimes performed worse than random chance on certain tasks. NeuTraL AD was the only method that never flipped. It didn't just win on average. It was more reliably correct.
For images, the picture is more nuanced. When working directly on raw pixels, the learned transformations didn't outperform hand crafted rotations and flips, which experts have refined over years. But when applied to features extracted by a pretrained image model, the system became competitive and in some settings superior, including beating the state of the art on detecting out of distribution samples from CIFAR datasets.
The Relationship to an Older Idea
The paper takes time to establish a theoretical connection between NeuTraL AD and one of the most influential older approaches to anomaly detection, a method called Deep One Class Classification.
The older approach works by training a neural network to map all normal samples as close as possible to a single fixed point in an abstract space. Anomalies end up far from that point because the network was never trained to pull them in. The distance from the centre becomes the anomaly score.
The researchers show mathematically that their system generalises this idea. With a specific choice of similarity function, NeuTraL AD reduces to a version of one class classification, but with several improvements baked in. Instead of a single fixed centre, each data point gets its own reference point that adapts during training. Instead of a single view of each sample, multiple views are extracted and compared. The diversity requirement prevents all the views from collapsing to the same thing, which is a failure mode that simpler methods are prone to.
The connection isn't just theoretical tidiness. It explains why NeuTraL AD tends to win in practice. It's doing something that the older method was trying to do, but with more degrees of freedom and better protection against the trivial solutions that make simpler approaches break down.
A Note on What's Still Hard
The paper is candid about where the method runs into limits.
On raw images, the hand crafted transformations that experts have developed, rotations, flips, crops, colour shifts, still outperform what the system learns from scratch. There's accumulated human knowledge baked into those choices, and the learned system doesn't yet match it on pixels alone. The authors suggest this is because learned transformations on raw images tend to focus on local texture features rather than the higher level structural information that makes a good self supervision task.
The fix they found, applying the learned transformations to pretrained image features rather than raw pixels, works well. But it means the approach benefits from a powerful pretrained model that someone else has already built, rather than working entirely from scratch.
For tabular data with very high variance in the normal distribution, meaning cases where normal itself covers an enormous range of possible values, nearest neighbour methods sometimes hold an edge. The authors demonstrate this in experiments where they gradually increase the number of normal classes, showing that all methods degrade but KNN based approaches degrade more gracefully in some settings.
These aren't fatal weaknesses. They're calibrations on where the method shines and where it faces the same challenges as everything else.
Why the Loss Function Is the Right Tool
There's a theoretical thread running through the paper that deserves a moment. The team proves, rather than just observes, that earlier attempts to use contrastive losses for learning data transformations lead to degenerate solutions.
If you ask a system to simply make the transformed versions look like the original, the easiest solution is to make all the transformations identical to each other. Nothing changes. No information is gained. If you ask it only to make the transformations look different from each other, the system can satisfy that constraint by producing completely random output, discarding all the original information. Both extremes are worthless for anomaly detection.
The Deterministic Contrastive Loss is constructed so that neither extreme is optimal. The theoretical analysis shows that the sweet spot, where transformations are both semantically faithful and mutually distinct, is the minimum of the loss function. Gradient descent will find it. The two objectives push against each other until a useful balance emerges.
The ablation studies in the paper confirm this empirically. When they tilt the balance toward one objective or the other, performance drops. The default balanced setting wins across every configuration they test.
Where This Lands
The practical case for a method like this is straightforward. Anomaly detection is a problem that shows up everywhere: fraud detection, medical diagnosis, quality control, network security, scientific discovery. In most of those domains, the people with domain knowledge to design good transformations by hand are not the same people building the detection systems. Bridging that gap requires either long collaboration or a method that can figure things out for itself.
NeuTraL AD doesn't fully automate expertise. You still need to choose an appropriate neural architecture for the transformations, and the specific choices differ between time series, graphs, and text. But the core task of figuring out which features of the data matter most for spotting anomalies, that gets handed off to the optimisation process.
The system learns what's worth paying attention to. Then it uses that knowledge to notice when something isn't paying attention in the right way.
Publication details: Year of publication: 2025 Journal: IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 47, No. 3 DOI: https://doi.org/10.1109/TPAMI.2024.3519543
Credit & Disclaimer: This article is based on the original research paper "Self-Supervised Anomaly Detection With Neural Transformations," published in IEEE Transactions on Pattern Analysis and Machine Intelligence (2025) following rigorous scientific review. Readers are encouraged to consult the full research article for complete methodology, data, and scientific detail.






