PyTorch implementation of Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy

Overview

Anomaly Transformer in PyTorch

This is an implementation of Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy. This paper has been accepted as a Spotlight Paper at ICLR 2022.

Repository currently a work in progress.

Usage

Requirements

Install dependences into a virtualenv:

$ python -m venv env
$ source env/bin/activate
(env) $ pip install -r requirements.txt

Written with python version 3.8.11

Data and Configuration

Custom datasets can be placed in the data/ dir. Edits should be made to the conf/data/default.yaml file to reflect the correct properties of the data. All other configuration hyperparameters can be set in the hydra configs.

Train

Once properly configured, a model can be trained via python train.py.

Citations

@misc{xu2021anomaly,
      title={Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy},
      author={Jiehui Xu and Haixu Wu and Jianmin Wang and Mingsheng Long},
      year={2021},
      eprint={2110.02642},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}
You might also like...
Demo project for real time anomaly detection using kafka and python
Demo project for real time anomaly detection using kafka and python

kafkaml-anomaly-detection Project for real time anomaly detection using kafka and python It's assumed that zookeeper and kafka are running in the loca

CLEAR algorithm for multi-view data association
CLEAR algorithm for multi-view data association

CLEAR: Consistent Lifting, Embedding, and Alignment Rectification Algorithm The Matlab, Python, and C++ implementation of the CLEAR algorithm, as desc

graph-theoretic framework for robust pairwise data association
graph-theoretic framework for robust pairwise data association

CLIPPER: A Graph-Theoretic Framework for Robust Data Association Data association is a fundamental problem in robotics and autonomy. CLIPPER provides

Groceries ARL: Association Rules (Birliktelik Kuralı)

Groceries_ARL Association Rules (Birliktelik Kuralı) Birliktelik kuralları, mark

Real-world Anomaly Detection in Surveillance Videos- pytorch Re-implementation

Real world Anomaly Detection in Surveillance Videos : Pytorch RE-Implementation This repository is a re-implementation of "Real-world Anomaly Detectio

A PyTorch implementation of
A PyTorch implementation of "ANEMONE: Graph Anomaly Detection with Multi-Scale Contrastive Learning", CIKM-21

ANEMONE A PyTorch implementation of "ANEMONE: Graph Anomaly Detection with Multi-Scale Contrastive Learning", CIKM-21 Dependencies python==3.6.1 dgl==

Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting
Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting

Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting This is the origin Pytorch implementation of Informer in the followin

This repo contains the code required to train the multivariate time-series Transformer.

Multi-Variate Time-Series Transformer This repo contains the code required to train the multivariate time-series Transformer. Download the data The No

Comments
  • update model.py

    update model.py

    Hi, thanks for sharing codes. I tried to revise the model according to your paper. 1). Fixed KL divergency calculation bug. 2). Added feature for supporting batch processing. (input: [batch, N, d]) 3). Fixed problem when the dimension of input is not equal to that of Transformer. ( d != d_model)

    opened by hyli666 0
  • Hi, I have a question !

    Hi, I have a question !

    Your research is very impressive and wonderful. However, I have one question while reading the paper.

    in this paper, For the maximize phase, we optimize the series-association to enlarge the association discrepancy. This process forces the series-association to pay more attention to the non-adjacent horizon.

    Maximize phases seem to focus more on series-association on adjacent horizon, but why is this non-adjacent horizon?

    In my opinion, if the sigma of the prior association is much less than 1, the series association will only look at more adjacent areas.

    Thank you image

    opened by Yoontae6719 0
  • Incorrect prior_association() ?

    Incorrect prior_association() ?

    It seems the method prior_association() can not back propagate gradient to train Ws, or maybe I misunderstood? https://github.com/spencerbraun/anomaly_transformer_pytorch/blob/6d15200911260eee910a3664d70f07886c47708b/model.py#L41-L45

    according to paper, is this the right way? gaussian = 1 / math.sqrt(2 * math.pi) / self.sigma * torch.exp(- 0.5 * (p / self.sigma).pow(2))

    opened by sappersapper 4
  • Loss for minimize and maximize phase

    Loss for minimize and maximize phase

    There is an issue with the loss: https://github.com/spencerbraun/anomaly_transformer_pytorch/blob/6d15200911260eee910a3664d70f07886c47708b/train.py#L53 the reconstruction loss cancels, and we only end up with -2*discrepancy loss. Additionally, the stop-gradient as described in the paper is not implemented.

    opened by raphaelreinauer 7
Owner
spencerbraun
NLP Researcher @PrimerAI.
spencerbraun
Code for the paper "TadGAN: Time Series Anomaly Detection Using Generative Adversarial Networks"

TadGAN: Time Series Anomaly Detection Using Generative Adversarial Networks This is a Python3 / Pytorch implementation of TadGAN paper. The associated

Arun 92 Dec 3, 2022
Time-series-deep-learning - Developing Deep learning LSTM, BiLSTM models, and NeuralProphet for multi-step time-series forecasting of stock price.

Stock Price Prediction Using Deep Learning Univariate Time Series Predicting stock price using historical data of a company using Neural networks for

Abdultawwab Safarji 7 Nov 27, 2022
Pytorch Implementation for NeurIPS (oral) paper: Pixel Level Cycle Association: A New Perspective for Domain Adaptive Semantic Segmentation

Pixel-Level Cycle Association This is the Pytorch implementation of our NeurIPS 2020 Oral paper Pixel-Level Cycle Association: A New Perspective for D

null 87 Oct 19, 2022
Code for our CVPR 2022 Paper "GEN-VLKT: Simplify Association and Enhance Interaction Understanding for HOI Detection"

GEN-VLKT Code for our CVPR 2022 paper "GEN-VLKT: Simplify Association and Enhance Interaction Understanding for HOI Detection". Contributed by Yue Lia

Yue Liao 47 Dec 4, 2022
Implementation of ETSformer, state of the art time-series Transformer, in Pytorch

ETSformer - Pytorch Implementation of ETSformer, state of the art time-series Transformer, in Pytorch Install $ pip install etsformer-pytorch Usage im

Phil Wang 121 Dec 30, 2022
A Pytorch implement of paper "Anomaly detection in dynamic graphs via transformer" (TADDY).

TADDY: Anomaly detection in dynamic graphs via transformer This repo covers an reference implementation for the paper "Anomaly detection in dynamic gr

Yue Tan 21 Nov 24, 2022
Official PyTorch code for WACV 2022 paper "CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows"

CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows WACV 2022 preprint:https://arxiv.org/abs/2107.1

Denis 156 Dec 28, 2022
Time Series Forecasting with Temporal Fusion Transformer in Pytorch

Forecasting with the Temporal Fusion Transformer Multi-horizon forecasting often contains a complex mix of inputs – including static (i.e. time-invari

Nicolás Fornasari 6 Jan 24, 2022
Implementation of association rules mining algorithms (Apriori|FPGrowth) using python.

Association Rules Mining Using Python Implementation of association rules mining algorithms (Apriori|FPGrowth) using python. As a part of hw1 code in

Pre 2 Nov 10, 2021
Implementation of the paper NAST: Non-Autoregressive Spatial-Temporal Transformer for Time Series Forecasting.

Non-AR Spatial-Temporal Transformer Introduction Implementation of the paper NAST: Non-Autoregressive Spatial-Temporal Transformer for Time Series For

Chen Kai 66 Nov 28, 2022