  Anomaly detection in time series has been widely researched and has important
practical applications. In recent years, anomaly detection algorithms are
mostly based on deep-learning generative models and use the reconstruction
error to detect anomalies. They try to capture the distribution of normal data
by reconstructing normal data in the training phase, then calculate the
reconstruction error of test data to do anomaly detection. However, most of
them only use the normal data in the training phase and can not ensure the
reconstruction process of anomaly data. So, anomaly data can also be well
reconstructed sometimes and gets low reconstruction error, which leads to the
omission of anomalies. What's more, the neighbor information of data points in
time series data has not been fully utilized in these algorithms. In this
paper, we propose RAN based on the idea of Reconstruct Anomalies to Normal and
apply it for unsupervised time series anomaly detection. To minimize the
reconstruction error of normal data and maximize this of anomaly data, we do
not just ensure normal data to reconstruct well, but also try to make the
reconstruction of anomaly data consistent with the distribution of normal data,
then anomalies will get higher reconstruction errors. We implement this idea by
introducing the "imitated anomaly data" and combining a specially designed
latent vector-constrained Autoencoder with the discriminator to construct an
adversary network. Extensive experiments on time-series datasets from different
scenes such as ECG diagnosis also show that RAN can detect meaningful
anomalies, and it outperforms other algorithms in terms of AUC-ROC.
