Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs in TCN networks; #2

Open
wants to merge 91 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
bb80b78
add DCdetector
real-lhj Sep 6, 2023
0833c20
add DCdetector
real-lhj Sep 6, 2023
fb5711b
add DCdetector
real-lhj Sep 6, 2023
07121ce
add DCdetector test file
real-lhj Sep 7, 2023
76f1f69
Update REASME.rst
real-lhj Sep 7, 2023
8f0e517
Update REASME.rst
real-lhj Sep 7, 2023
7adfca0
Merge branch 'xuhongzuo:main' into main
real-lhj Sep 7, 2023
cbf76c1
Update requirements_ci.yml
real-lhj Sep 7, 2023
bbc9723
fix bugs in TCN networks;
xuhongzuo Sep 7, 2023
82553c6
Update requirements.txt
real-lhj Sep 7, 2023
83218af
fix bugs in TCN networks
real-lhj Sep 7, 2023
e337593
fix bugs in TCN networks
real-lhj Sep 7, 2023
96a65eb
commits1
real-lhj Sep 7, 2023
c53d99f
commits2
real-lhj Sep 7, 2023
97fb54c
:boom: major update: add ray (auto hyper-parameter tuning tool) to De…
xuhongzuo Sep 9, 2023
db59630
:boom: major update: add ray (auto hyper-parameter tuning tool) to De…
xuhongzuo Sep 9, 2023
b14c428
:boom: major update: add ray (auto hyper-parameter tuning tool) to De…
xuhongzuo Sep 9, 2023
a752600
fix bugs in requirements.txt
xuhongzuo Sep 9, 2023
9d5ff3f
merge from xuhongzuo-main
real-lhj Sep 12, 2023
9b582d1
feat :sparkles: : Load and save models functiona
elsheikh21 Sep 18, 2023
ff43182
fix bugs in couta.py and test_rdp.py
xuhongzuo Sep 21, 2023
859e902
fix bugs in couta.py and test_rdp.py
xuhongzuo Sep 21, 2023
0015128
Merge pull request #35 from real-lhj/main
xuhongzuo Sep 21, 2023
7123744
commits to merge
xuhongzuo Sep 21, 2023
09eca95
Merge branch 'main' of https://github.com/xuhongzuo/DeepOD
xuhongzuo Sep 21, 2023
79d1c6b
Merge pull request #36 from elsheikh21/feat_load_and_save_mdls
xuhongzuo Sep 22, 2023
94f8f9d
commits to merge
xuhongzuo Sep 22, 2023
d60f6d3
Merge branch 'main' of https://github.com/xuhongzuo/DeepOD
xuhongzuo Sep 22, 2023
c7e384a
feature: add save/load model in base_model.py
xuhongzuo Sep 22, 2023
40d1740
Add files via upload
nuhdv Oct 22, 2023
650689f
Add files via upload
nuhdv Oct 22, 2023
2bbd126
Merge pull request #37 from nuhdv/main
xuhongzuo Oct 22, 2023
99dbfb2
tentatively remove test_flad.py
xuhongzuo Oct 25, 2023
d844e0c
Update utils.py
crishna0401 Oct 28, 2023
3dc3cb5
Update README.rst
xuhongzuo Nov 6, 2023
43bbcae
doc init
xuhongzuo Nov 7, 2023
4987c7b
doc init
xuhongzuo Nov 7, 2023
5942ef5
doc init
xuhongzuo Nov 7, 2023
59d2d75
doc init
xuhongzuo Nov 7, 2023
3791af8
doc init
xuhongzuo Nov 7, 2023
95d578e
doc init
xuhongzuo Nov 7, 2023
cb245f3
doc init
xuhongzuo Nov 7, 2023
f6c5ed0
doc init
xuhongzuo Nov 7, 2023
c6633a1
doc init
xuhongzuo Nov 7, 2023
3a2c74d
Add files via upload
yyysjz1997 Nov 8, 2023
6d970e0
Add files via upload
yyysjz1997 Nov 8, 2023
506c2b7
Delete deepod/core/__pycache__/__init__.cpython-39.pyc
yyysjz1997 Nov 9, 2023
aa0ef51
Delete deepod/core/__pycache__/base_model.cpython-39.pyc
yyysjz1997 Nov 9, 2023
84e7dba
Delete deepod/core/__pycache__/base_networks.cpython-39.pyc
yyysjz1997 Nov 9, 2023
b4cda6b
Delete deepod/metrics/affiliation/__init__.py
yyysjz1997 Nov 9, 2023
112484f
doc init
xuhongzuo Nov 9, 2023
54dbe70
doc init
xuhongzuo Nov 9, 2023
cd4a796
doc init
xuhongzuo Nov 9, 2023
119c8ea
doc init
xuhongzuo Nov 9, 2023
f1a6951
change doc's requirements.txt
xuhongzuo Nov 9, 2023
8c6ab24
update .readthedocs.yaml
xuhongzuo Nov 9, 2023
754933f
update README.rst
xuhongzuo Nov 9, 2023
f56e108
update README.rst
xuhongzuo Nov 9, 2023
0278174
update README.rst
xuhongzuo Nov 9, 2023
cbcdd31
Merge branch 'main' into main
xuhongzuo Nov 9, 2023
bdbfc90
Merge pull request #41 from yyysjz1997/main
xuhongzuo Nov 9, 2023
9dee44b
update README.rst
xuhongzuo Nov 9, 2023
a1c3f6e
Merge branch 'main' of https://github.com/xuhongzuo/DeepOD
xuhongzuo Nov 9, 2023
dbede6f
fix bugs in test files
xuhongzuo Nov 10, 2023
5dd4cfb
fix bugs in test files
xuhongzuo Nov 10, 2023
06d7562
fix bugs in test files
xuhongzuo Nov 10, 2023
5e7a076
fix bugs in test files
xuhongzuo Nov 10, 2023
254b7f1
fix bugs in test files
xuhongzuo Nov 10, 2023
c2c7566
remove some unused dependencies in metrics
xuhongzuo Nov 10, 2023
96f5f66
Remove deprecated tuple syntax for hidden_dims
NAThompson Nov 15, 2023
2362655
Make the minimum seq_len equal to the number of rows.
NAThompson Nov 15, 2023
3f2bcd2
Add code comments for documentation
yyysjz1997 Nov 19, 2023
312d7ad
Update base_model.py
yyysjz1997 Nov 19, 2023
e50de07
Add code comments for documentation
yyysjz1997 Nov 19, 2023
96c34e7
Add code comments for documentation
yyysjz1997 Nov 21, 2023
eb18ea1
Add code comments for documentation
yyysjz1997 Nov 26, 2023
622e28e
fix the import error in testbed (Issue #48)
xuhongzuo Dec 11, 2023
acdc813
Merge remote-tracking branch 'origin/main'
xuhongzuo Dec 11, 2023
e3fe697
change the default parameters in time_series/dif.py (Issue #46)
xuhongzuo Dec 11, 2023
f790ee5
Merge pull request #46 from NAThompson/deprecation_response
xuhongzuo Dec 11, 2023
a1ec53a
Merge pull request #39 from crishna0401/main
xuhongzuo Dec 11, 2023
b4d24e4
fix bugs
xuhongzuo Dec 12, 2023
4b2adfa
update
xuhongzuo Mar 27, 2024
6a2118b
add testing advanced metrics of tsad
xuhongzuo Mar 27, 2024
af4db6c
remove unused code in metrics
xuhongzuo May 25, 2024
f351a87
remove unused code in metrics
xuhongzuo May 25, 2024
7654813
remove unused code in metrics
xuhongzuo May 26, 2024
bd91d0b
Update README.rst
xuhongzuo Jun 9, 2024
8f32ab3
Merge pull request #47 from NAThompson/min_seq_len
xuhongzuo Jun 10, 2024
2a2b200
Update README.rst
xuhongzuo Sep 14, 2024
bb8c20c
Update README.rst
xuhongzuo Sep 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build/
.idea
**/__pycache__
docs_output
docs/generated
.vscode
sphinx-build
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
python: "3.8"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
Expand Down
75 changes: 55 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Python Deep Outlier/Anomaly Detection (DeepOD)
:target: https://github.com/xuhongzuo/DeepOD/actions/workflows/testing.yml
:alt: testing2

.. image:: https://readthedocs.org/projects/deepod/badge/?version=latest
:target: https://deepod.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://app.codacy.com/project/badge/Grade/2c587126aac2441abb917c032189fbe8
:target: https://app.codacy.com/gh/xuhongzuo/DeepOD/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
:alt: codacy

.. image:: https://coveralls.io/repos/github/xuhongzuo/DeepOD/badge.svg?branch=main
:target: https://coveralls.io/github/xuhongzuo/DeepOD?branch=main
:alt: coveralls
Expand All @@ -18,7 +26,7 @@ Python Deep Outlier/Anomaly Detection (DeepOD)
and `Anomaly Detection <https://en.wikipedia.org/wiki/Anomaly_detection>`_. ``DeepOD`` supports tabular anomaly detection and time-series anomaly detection.


DeepOD includes **26** deep outlier detection / anomaly detection algorithms (in unsupervised/weakly-supervised paradigm).
DeepOD includes **27** deep outlier detection / anomaly detection algorithms (in unsupervised/weakly-supervised paradigm).
More baseline algorithms will be included later.


Expand Down Expand Up @@ -169,14 +177,14 @@ Implemented Models
RCA, IJCAI, 2021, unsupervised, RCA: A Deep Collaborative Autoencoder Approach for Anomaly Detection [#Liu2021RCA]_
GOAD, ICLR, 2020, unsupervised, Classification-Based Anomaly Detection for General Data [#Bergman2020GOAD]_
NeuTraL, ICML, 2021, unsupervised, Neural Transformation Learning for Deep Anomaly Detection Beyond Images [#Qiu2021Neutral]_
ICL, ICLR, 2022, unsupervised, Anomaly Detection for Tabular Data with Internal Contrastive Learning
DIF, TKDE, 2023, unsupervised, Deep Isolation Forest for Anomaly Detection
SLAD, ICML, 2023, unsupervised, Fascinating Supervisory Signals and Where to Find Them: Deep Anomaly Detection with Scale Learning
DevNet, KDD, 2019, weakly-supervised, Deep Anomaly Detection with Deviation Networks
PReNet, KDD, 2023, weakly-supervised, Deep Weakly-supervised Anomaly Detection
Deep SAD, ICLR, 2020, weakly-supervised, Deep Semi-Supervised Anomaly Detection
FeaWAD, TNNLS, 2021, weakly-supervised, Feature Encoding with AutoEncoders for Weakly-supervised Anomaly Detection
RoSAS, IP&M, 2023, weakly-supervised, RoSAS: Deep semi-supervised anomaly detection with contamination-resilient continuous supervision
ICL, ICLR, 2022, unsupervised, Anomaly Detection for Tabular Data with Internal Contrastive Learning [#Shenkar2022ICL]_
DIF, TKDE, 2023, unsupervised, Deep Isolation Forest for Anomaly Detection [#Xu2023DIF]_
SLAD, ICML, 2023, unsupervised, Fascinating Supervisory Signals and Where to Find Them: Deep Anomaly Detection with Scale Learning [#Xu2023SLAD]_
DevNet, KDD, 2019, weakly-supervised, Deep Anomaly Detection with Deviation Networks [#Pang2019DevNet]_
PReNet, KDD, 2023, weakly-supervised, Deep Weakly-supervised Anomaly Detection [#Pang2023PreNet]_
Deep SAD, ICLR, 2020, weakly-supervised, Deep Semi-Supervised Anomaly Detection [#Ruff2020DSAD]_
FeaWAD, TNNLS, 2021, weakly-supervised, Feature Encoding with AutoEncoders for Weakly-supervised Anomaly Detection [#Zhou2021FeaWAD]_
RoSAS, IP&M, 2023, weakly-supervised, RoSAS: Deep semi-supervised anomaly detection with contamination-resilient continuous supervision [#Xu2023RoSAS]_

**Time-series Anomaly Detection models:**

Expand All @@ -187,15 +195,16 @@ Implemented Models
DCdetector, KDD, 2023, unsupervised, DCdetector: Dual Attention Contrastive Representation Learning for Time Series Anomaly Detection [#Yang2023dcdetector]_
TimesNet, ICLR, 2023, unsupervised, TIMESNET: Temporal 2D-Variation Modeling for General Time Series Analysis [#Wu2023timesnet]_
AnomalyTransformer, ICLR, 2022, unsupervised, Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy [#Xu2022transformer]_
TranAD, VLDB, 2022, unsupervised, TranAD: Deep Transformer Networks for Anomaly Detection in Multivariate Time Series Data
COUTA, arXiv, 2022, unsupervised, Calibrated One-class Classification for Unsupervised Time Series Anomaly Detection
NCAD, IJCAI, 2022, unsupervised, Neural Contextual Anomaly Detection for Time Series [#Carmona2022NCAD]_
TranAD, VLDB, 2022, unsupervised, TranAD: Deep Transformer Networks for Anomaly Detection in Multivariate Time Series Data [#Tuli2022TranAD]_
COUTA, arXiv, 2022, unsupervised, Calibrated One-class Classification for Unsupervised Time Series Anomaly Detection [#Xu2022COUTA]_
USAD, KDD, 2020, unsupervised, USAD: UnSupervised Anomaly Detection on Multivariate Time Series
DIF, TKDE, 2023, unsupervised, Deep Isolation Forest for Anomaly Detection
TcnED, TNNLS, 2021, unsupervised, An Evaluation of Anomaly Detection and Diagnosis in Multivariate Time Series
Deep SVDD (TS), ICML, 2018, unsupervised, Deep One-Class Classification
DevNet (TS), KDD, 2019, weakly-supervised, Deep Anomaly Detection with Deviation Networks
PReNet (TS), KDD, 2023, weakly-supervised, Deep Weakly-supervised Anomaly Detection
Deep SAD (TS), ICLR, 2020, weakly-supervised, Deep Semi-Supervised Anomaly Detection
DIF, TKDE, 2023, unsupervised, Deep Isolation Forest for Anomaly Detection [#Xu2023DIF]_
TcnED, TNNLS, 2021, unsupervised, An Evaluation of Anomaly Detection and Diagnosis in Multivariate Time Series [#Garg2021Evaluation]_
Deep SVDD (TS), ICML, 2018, unsupervised, Deep One-Class Classification [#Ruff2018Deep]_
DevNet (TS), KDD, 2019, weakly-supervised, Deep Anomaly Detection with Deviation Networks [#Pang2019DevNet]_
PReNet (TS), KDD, 2023, weakly-supervised, Deep Weakly-supervised Anomaly Detection [#Pang2023PreNet]_
Deep SAD (TS), ICLR, 2020, weakly-supervised, Deep Semi-Supervised Anomaly Detection [#Ruff2020DSAD]_

NOTE:

Expand Down Expand Up @@ -252,8 +261,34 @@ Reference

.. [#Qiu2021Neutral] Qiu, Chen, et al. "Neural Transformation Learning for Deep Anomaly Detection Beyond Images". ICML. 2021.

.. [#Xu2022transformer] Xu Jiehui, et al. "Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy". ICLR, 2022.
.. [#Shenkar2022ICL] Shenkar, Tom, et al. "Anomaly Detection for Tabular Data with Internal Contrastive Learning". ICLR. 2022.

.. [#Pang2019DevNet] Pang, Guansong, et al. "Deep Anomaly Detection with Deviation Networks". KDD. 2019.

.. [#Pang2023PreNet] Pang, Guansong, et al. "Deep Weakly-supervised Anomaly Detection". KDD. 2023.

.. [#Ruff2020DSAD] Ruff, Lukas, et al. "Deep Semi-Supervised Anomaly Detection". ICLR. 2020.

.. [#Zhou2021FeaWAD] Zhou, Yingjie, et al. "Feature Encoding with AutoEncoders for Weakly-supervised Anomaly Detection". TNNLS. 2021.

.. [#Xu2022transformer] Xu, Jiehui, et al. "Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy". ICLR, 2022.

.. [#Wu2023timesnet] Wu, Haixu, et al. "TimesNet: Temporal 2D-Variation Modeling for General Time Series Analysis". ICLR. 2023.

.. [#Yang2023dcdetector] Yang, Yiyuan, et al. "DCdetector: Dual Attention Contrastive Representation Learning for Time Series Anomaly Detection". KDD. 2023

.. [#Tuli2022TranAD] Tuli, Shreshth, et al. "TranAD: Deep Transformer Networks for Anomaly Detection in Multivariate Time Series Data". VLDB. 2022.

.. [#Carmona2022NCAD] Carmona, Chris U., et al. "Neural Contextual Anomaly Detection for Time Series". IJCAI. 2022.

.. [#Garg2021Evaluation] Garg, Astha, et al. "An Evaluation of Anomaly Detection and Diagnosis in Multivariate Time Series". TNNLS. 2021.

.. [#Xu2022COUTA] Xu, Hongzuo et al. "Calibrated One-class Classification for Unsupervised Time Series Anomaly Detection". arXiv:2207.12201. 2022.

.. [#Xu2023DIF] Xu, Hongzuo et al. "Deep Isolation Forest for Anomaly Detection". TKDE. 2023.

.. [#Xu2023SLAD] Xu, Hongzuo et al. "Fascinating supervisory signals and where to find them: deep anomaly detection with scale learning". ICML. 2023.

.. [#Xu2023RoSAS] Xu, Hongzuo et al. "RoSAS: Deep semi-supervised anomaly detection with contamination-resilient continuous supervision". IP&M. 2023.

.. [#Wu2023timesnet] Wu Haixu, et al. "TimesNet: Temporal 2D-Variation Modeling for General Time Series Analysis". ICLR. 2023.

.. [#Yang2023dcdetector] Yang Yiyuan et al. "DCdetector: Dual Attention Contrastive Representation Learning for Time Series Anomaly Detection". KDD. 2023
1 change: 1 addition & 0 deletions deepod/core/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from deepod.utils.utility import get_sub_seqs, get_sub_seqs_label
import pickle


class BaseDeepAD(metaclass=ABCMeta):
"""
Abstract class for deep outlier detection models
Expand Down
12 changes: 12 additions & 0 deletions deepod/core/networks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .base_networks import MLPnet
from .base_networks import MlpAE
from .base_networks import GRUNet
from .base_networks import LSTMNet
from .base_networks import ConvSeqEncoder
from .base_networks import ConvNet
from .ts_network_transformer import TSTransformerEncoder
from .ts_network_tcn import TCNnet
from .ts_network_tcn import TcnAE

__all__ = ['MLPnet', 'MlpAE', 'GRUNet', 'LSTMNet', 'ConvSeqEncoder',
'ConvNet', 'TSTransformerEncoder', 'TCNnet', 'TcnAE']
32 changes: 28 additions & 4 deletions deepod/core/networks/base_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from deepod.core.networks.ts_network_tcn import TCNnet, TcnAE
# from deepod.core.base_transformer_network_dev import TSTransformerEncoder
from deepod.core.networks.network_utility import _instantiate_class, _handle_n_hidden

import torch.nn.modules.activation

sequential_net_name = ['TCN', 'GRU', 'LSTM', 'Transformer', 'ConvSeq', 'DilatedConv']

Expand All @@ -32,6 +32,26 @@ def get_network(network_name):


class ConvNet(torch.nn.Module):
"""Convolutional Network

Args:
n_features (int):
number of input data features
kernel_size (int):
kernel size (Default=1)
n_hidden (int):
number of hidden units in hidden layers (Default=8)
n_layers (int):
number of layers (Default=5)
activation (str):
name of activation layer,
activation should be implemented in torch.nn.module.activation
(Default='ReLU')
bias (bool):
use bias or not
(Default=False)

"""
def __init__(self, n_features, kernel_size=1, n_hidden=8, n_layers=5,
activation='ReLU', bias=False):
super(ConvNet, self).__init__()
Expand All @@ -49,7 +69,7 @@ def __init__(self, n_features, kernel_size=1, n_hidden=8, n_layers=5,
self.layers += [
# torch.nn.LeakyReLU(inplace=True)
_instantiate_class(module_name="torch.nn.modules.activation",
class_name=activation)
class_name=activation)
]
in_channels = n_hidden

Expand All @@ -62,6 +82,7 @@ def forward(self, x):


class MlpAE(torch.nn.Module):
"""MLP-based AutoEncoder"""
def __init__(self, n_features, n_hidden='500,100', n_emb=20, activation='ReLU',
bias=False, batch_norm=False,
skip_connection=None, dropout=None
Expand Down Expand Up @@ -105,6 +126,7 @@ def forward(self, x):


class MLPnet(torch.nn.Module):
"""MLP-based Representation Network"""
def __init__(self, n_features, n_hidden='500,100', n_output=20, mid_channels=None,
activation='ReLU', bias=False, batch_norm=False,
skip_connection=None, dropout=None):
Expand Down Expand Up @@ -140,7 +162,6 @@ def __init__(self, n_features, n_hidden='500,100', n_output=20, mid_channels=Non
]
self.network = torch.nn.Sequential(*self.layers)


def forward(self, x):
x = self.network(x)
return x
Expand All @@ -158,6 +179,7 @@ def get_in_out_channels(self, i, num_layers, n_features, n_hidden, n_output, ski


class LinearBlock(torch.nn.Module):
"""Linear Block"""
def __init__(self, in_channels, out_channels, mid_channels=None,
activation='Tanh', bias=False, batch_norm=False,
skip_connection=None, dropout=None):
Expand Down Expand Up @@ -214,6 +236,7 @@ def forward(self, x):


class GRUNet(torch.nn.Module):
"""GRU Network"""
def __init__(self, n_features, n_hidden='20', n_output=20,
bias=False, dropout=None, activation='ReLU'):
super(GRUNet, self).__init__()
Expand All @@ -235,8 +258,8 @@ def forward(self, x):
return out



class LSTMNet(torch.nn.Module):
"""LSTM Network"""
def __init__(self, n_features, n_hidden='20', n_output=20,
bias=False, dropout=None, activation='ReLU'):
super(LSTMNet, self).__init__()
Expand Down Expand Up @@ -309,6 +332,7 @@ def forward(self, x):


class ConvResBlock(torch.nn.Module):
"""Convolutional Residual Block"""
def __init__(self, in_dim, out_dim, conv_param=None, down_sample=None,
batch_norm=False, bias=False, activation='ReLU'):
super(ConvResBlock, self).__init__()
Expand Down
5 changes: 4 additions & 1 deletion deepod/core/networks/ts_network_tcn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# TCN is partially adapted from https://github.com/locuslab/TCN

import torch
from torch.nn.utils import weight_norm
from deepod.core.networks.network_utility import _instantiate_class, _handle_n_hidden


class TcnAE(torch.nn.Module):
"""Temporal Convolutional Network-based AutoEncoder"""
def __init__(self, n_features, n_hidden='500,100', n_emb=20, activation='ReLU', bias=False,
kernel_size=2, dropout=0.2):
super(TcnAE, self).__init__()
Expand Down Expand Up @@ -60,7 +63,7 @@ def forward(self, x):


class TCNnet(torch.nn.Module):
"""TCN is adapted from https://github.com/locuslab/TCN"""
"""Temporal Convolutional Network (TCN) for encoding/representing input time series sequences"""
def __init__(self, n_features, n_hidden='8', n_output=20,
kernel_size=2, bias=False,
dropout=0.2, activation='ReLU'):
Expand Down
13 changes: 5 additions & 8 deletions deepod/core/networks/ts_network_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,13 @@ def forward(self, src, src_mask=None, src_key_padding_mask=None):
return src




class TSTransformerEncoder(torch.nn.Module):
"""
Simplest classifier/regressor. Can be either regressor or classifier because the output does not include
softmax. Concatenates final layer embeddings and uses 0s to ignore padding embeddings in final output layer.
Transformer for encoding/representing input time series sequences
"""

def __init__(self, n_features, n_output=20, seq_len=100, d_model=128,
n_heads=8, n_hidden='128', dropout=0.1,
n_heads=8, n_hidden='512', dropout=0.1,
token_encoding='convolutional', pos_encoding='fixed', activation='GELU', bias=False,
attn='self_attn', norm='LayerNorm', freeze=False):
super(TSTransformerEncoder, self).__init__()
Expand All @@ -290,11 +287,11 @@ def __init__(self, n_features, n_output=20, seq_len=100, d_model=128,
n_hidden, n_layers = _handle_n_hidden(n_hidden)

# parameter check
assert token_encoding in ['linear', 'convolutional'], \
assert token_encoding in ['linear', 'convolutional'], \
f"use 'linear' or 'convolutional', {token_encoding} is not supported in token_encoding"
assert pos_encoding in ['learnable', 'fixed'],\
assert pos_encoding in ['learnable', 'fixed'],\
f"use 'learnable' or 'fixed', {pos_encoding} is not supported in pos_encoding"
assert norm in ['LayerNorm', 'BatchNorm'],\
assert norm in ['LayerNorm', 'BatchNorm'],\
f"use 'learnable' or 'fixed', {norm} is not supported in norm"

if token_encoding == 'linear':
Expand Down
8 changes: 7 additions & 1 deletion deepod/metrics/_tsad_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ def point_adjustment(y_true, y_score):
data label, 0 indicates normal timestamp, and 1 is anomaly

y_score: np.array, required
anomaly score, higher score indicates higher likelihoods to be anomaly
predicted anomaly scores, higher score indicates higher likelihoods to be anomaly

Returns
-------
score: np.array
adjusted anomaly scores

"""
score = y_score.copy()
assert len(score) == len(y_true)
Expand Down
5 changes: 3 additions & 2 deletions deepod/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
from deepod.models.time_series.dcdetector import DCdetector
from deepod.models.time_series.timesnet import TimesNet
from deepod.models.time_series.anomalytransformer import AnomalyTransformer
from deepod.models.time_series.ncad import NCAD
from deepod.models.time_series.tranad import TranAD
from deepod.models.time_series.couta import COUTA
from deepod.models.time_series.usad import USAD
from deepod.models.time_series.tcned import TcnED


__all__ = [
'RCA', 'DeepSVDD', 'GOAD', 'NeuTraL', 'RDP', 'ICL', 'SLAD', 'DeepIsolationForest',
'DeepSAD', 'DevNet', 'PReNet', 'FeaWAD', 'REPEN', 'RoSAS',
'DCdetector', 'TimesNet', 'AnomalyTransformer', 'TranAD', 'COUTA', 'USAD', 'TcnED',
'DCdetector', 'TimesNet', 'AnomalyTransformer', 'NCAD',
'TranAD', 'COUTA', 'USAD', 'TcnED',
'DeepIsolationForestTS', 'DeepSVDDTS',
'PReNetTS', 'DeepSADTS', 'DevNetTS'
]
Loading