
AltUB: Alternating Training Method to Update Base Distribution of
Normalizing Flow for Anomaly Detection
Yeongmin Kim*1, Huiwon Jang*2, DongKeon Lee 3, Ho-Jin Choi 3
1School of Freshman, KAIST
2Department of Mathematical Science, KAIST
3School of Computing, KAIST
(cytotoxicity8 / huiwoen0516 / hagg30 / hojinc)@kaist.ac.kr
Abstract
Unsupervised anomaly detection is coming into the spotlight
these days in various practical domains due to the limited
amount of anomaly data. One of the major approaches for
it is a normalizing flow which pursues the invertible transfor-
mation of a complex distribution as images into an easy dis-
tribution as N(0, I). In fact, algorithms based on normalizing
flow like FastFlow and CFLOW-AD establish state-of-the-art
performance on unsupervised anomaly detection tasks. Nev-
ertheless, we investigate these algorithms convert normal im-
ages into not N(0, I)as their destination, but an arbitrary nor-
mal distribution. Moreover, their performances are often un-
stable, which is highly critical for unsupervised tasks because
data for validation are not provided. To break through these
observations, we propose a simple solution AltUB which in-
troduces alternating training to update the base distribution
of normalizing flow for anomaly detection. AltUB effectively
improves the stability of performance of normalizing flow.
Furthermore, our method achieves the new state-of-the-art
performance of the anomaly segmentation task on the MVTec
AD dataset with 98.8% AUROC.
1 Introduction
Automated detection of anomalies has become an important
area of computer vision in a variety of practical domains,
including industrial (Bergmann et al. 2019), medical (Zhou
et al. 2020) field, and autonomous driving systems (Jung
et al. 2021). The essential goal of anomaly detection (AD)
is to classify whether an object is normal or abnormal, and
localize the regions of an anomaly if the object is classified
as an anomaly (Wu et al. 2021). However, it is challenging
to obtain a large number of abnormal images in real-world
problems.
An unsupervised anomaly detection task has been intro-
duced to address this imbalance in the dataset due to the lack
of defected samples. To do so, it aims at detecting defection
by using only the non-defected samples. That is why many
recent approaches for unsupervised anomaly detection try to
obtain representations of normal data and detect anomalies
by comparing them with test samples’ representations.
Learning representations of normal data in an unsuper-
vised anomaly detection task is closely related to the goal
*These authors contributed equally.
Copyright © 2023, Association for the Advancement of Artificial
Intelligence (www.aaai.org). All rights reserved.
of normalizing flow: the model learns invertible mapping
of a complex distribution of normal samples into a simple
distribution such as the normal distribution. The original
usages of the normalizing flow are density estimation and
generating data efficiently using invertible mappings (Dinh,
Sohl-Dickstein, and Bengio 2017; Kingma and Dhariwal
2018), whereas some recent approaches (Rudolph, Wandt,
and Rosenhahn 2021; Yu et al. 2021; Gudovskiy, Ishizaka,
and Kozuka 2022) begin to utilize the normalizing flow to
tackle the unsupervised anomaly detection tasks. In partic-
ular, they have achieved state-of-the-art performance on the
MVTec AD (Bergmann et al. 2019) of the industrial domain.
Despite the success of normalizing flow-based anomaly
detection models, they have a limitation for the unsuper-
vised task: performances are unstable in many cases. Specif-
ically, their test performances often fluctuate while train-
ing the model for a long time (e.g. 200 or 400 epochs).
This drawback will be critical in every practical domain be-
cause one must use the unsupervised trained models that
have been trained sufficiently. One possible reason is the
limited expressive power of normalizing flow with the fixed
base (prior) distribution. Current approaches as Rudolph,
Wandt, and Rosenhahn (2021); Yu et al. (2021); Gudovskiy,
Ishizaka, and Kozuka (2022) fix the base distribution of nor-
malizing flow as N(0, I). However, as depicted in Figures 1
(b) and (c), most outputs of the model do not follow N(0, I),
while they utilize the likelihoods in the base distribution as
a score function:
−exp 1
|C|X
c∈C
−zT
czc
2!,(1)
where Cis an index set for output channels. Even the score
function requires an assumption for the theoretical validity
that normal samples are transformed to the base distribution
while training, it fails for the models to learn N(0, I). This
phenomenon occurs pervasively for normalizing flow-based
anomaly detection models.
To tackle this problem by considering the reason
mentioned above, we propose an algorithm called the
Alternating Training method to Update Base distribution
(AltUB) that performs better and learns more stably with
normalizing flow-based anomaly detection models. Our
method introduces alternating updates to learn a base dis-
tribution more actively and to allow the model to adapt to
arXiv:2210.14913v1 [cs.LG] 26 Oct 2022