Git Product home page Git Product logo

tsem's Introduction

TSEM

Implementation of TSEM: Temporally-Weighted Spatiotemporal Explainable Neural Network for Multivariate Time Series, in Pytorch

Install

$ pip install tsem

Basic Usage

import torch
from tsem.model import TSEM

series = torch.randn(1, 1, 256, 3)
window_size = series.shape[-2]
if window_size % 2 == 0:
    window_size -= 1

tsem = TSEM(
    window_size = window_size,
    time_length = series.shape[-2],
    feature_length = series.shape[-1],
    n_classes = 1000
)

preds = tsem(series) # (1, 1000)

Parameters

  • window_size: int.
    Window size along the time dimension. Must be smaller than time_length and odd number.
  • time_length: int.
    Length of the series.
  • feature_length: int.
    Number of series in the multivariate timeseries.
  • num_classes: int.
    Number of classes to classify.

Advanced Usage

  • Training
criterion = nn.CrossEntropyLoss()
optimizer_ft = torch.optim.Adam(model.parameters(), lr=1.5e-4)
exp_lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer_ft, step_size=10, gamma=0.1)

model = train_model(model, criterion, optimizer_ft, exp_lr_scheduler, dataloaders, datasets_size, 50)
  • Explaining
from tsem.feature_extractors.cams import XGradCAM
from tsem.utils.visualization import CAMFeatureMaps


extracting_model = model
extracting_module = model.cnn_layers1_b1
targeting_layer = "relu_12"

feature_maps = CAMFeatureMaps(XGradCAM)
feature_maps.load(extracting_model,extracting_module,targeting_layer,use_cuda=True)

mask1 = feature_maps.show(X_test[0], True, None, plot=True)
feature_maps.map_activation_to_input(mask1[0])
  • Further details, please have a look in examples/

Citation

@inproceedings{pham2023tsem,
  title={TSEM: Temporally-Weighted Spatiotemporal Explainable Neural Network for Multivariate Time Series},
  author={Pham, Anh-Duy and Kuestenmacher, Anastassia and Ploeger, Paul G},
  booktitle={Advances in Information and Communication: Proceedings of the 2023 Future of Information and Communication Conference (FICC), Volume 2},
  pages={183--204},
  year={2023},
  organization={Springer}
}

tsem's People

Contributors

a11to1n3 avatar

Stargazers

Hoang Nguyen Phuoc Bao avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.