• Stars
    star
    225
  • Rank 173,451 (Top 4 %)
  • Language
    Jupyter Notebook
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

TTS-GAN: A Transformer-based Time-Series Generative Adversarial Network

TTS-GAN: A Transformer-based Time-Series Generative Adversarial Network


This repository contains code from the paper "TTS-GAN: A Transformer-based Time-Series Generative Adversarial Network".

The paper has been accepted to publish in the 20th International Conference on Artificial Intelligence in Medicine (AIME 2022).

Please find the paper here


Abstract: Time-series datasets used in machine learning applications often are small in size, making the training of deep neural network architectures ineffective. For time series, the suite of data augmentation tricks we can use to expand the size of the dataset is limited by the need to maintain the basic properties of the signal. Data generated by a Generative Adversarial Network (GAN) can be utilized as another data augmentation tool. RNN-based GANs suffer from the fact that they cannot effectively model long sequences of data points with irregular temporal relations. To tackle these problems, we introduce TTS-GAN, a transformer-based GAN which can successfully generate realistic synthetic time series data sequences of arbitrary length, similar to the original ones. Both the generator and discriminator networks of the GAN model are built using a pure transformer encoder architecture. We use visualizations to demonstrate the similarity of real and generated time series and a simple classification task that shows how we can use synthetically generated data to augment real data and improve classification accuracy.


Key Idea:

Transformer GAN generate synthetic time-series data

The TTS-GAN Architecture

The TTS-GAN Architecture

The TTS-GAN model architecture is shown in the upper figure. It contains two main parts, a generator, and a discriminator. Both of them are built based on the transformer encoder architecture. An encoder is a composition of two compound blocks. A multi-head self-attention module constructs the first block and the second block is a feed-forward MLP with GELU activation function. The normalization layer is applied before both of the two blocks and the dropout layer is added after each block. Both blocks employ residual connections.

The time series data processing step

The time series data processing step

We view a time-series data sequence like an image with a height equal to 1. The number of time-steps is the width of an image, W. A time-series sequence can have a single channel or multiple channels, and those can be viewed as the number of channels (RGB) of an image, C. So an input sequence can be represented with the matrix of size (Batch Size, C, 1, W). Then we choose a patch size N to divide a sequence into W / N patches. We then add a soft positional encoding value by the end of each patch, the positional value is learned during model training. Each patch will then have the data shape (Batch Size, C, 1, (W/N) + 1) This process is shown in the upper figure.


Repository structures:

./images

Several images of the TTS-GAN project

./pre-trained-models

Saved pre-trained GAN model checkpoints

dataLoader.py

The UniMiB dataset dataLoader used for loading GAN model training/testing data

LoadRealRunningJumping.py

Load real running and jumping data from UniMiB dataset

LoadSyntheticRunningJumping.py

Load Synthetic running and jumping data from the pre-trained GAN models

functions.py

The GAN model training and evaluation functions

train_GAN.py

The major GAN model training file

visualizationMetrics.py

The help functions to draw T-SNE and PCA plots

adamw.py

The adamw function file

cfg.py

The parse function used for reading parameters to train_GAN.py file

JumpingGAN_Train.py

Run this file to start training the Jumping GAN model

RunningGAN_Train.py

Run this file to start training the Running GAN model


Code Instructions:

To train the Running data GAN model:

python RunningGAN_Train.py

To train the Jumping data GAN model:

python JumpingGAN_Train.py

A simple example of visualizing the similarity between the synthetic running&jumping data and the real running&jumping data:

Running&JumpingVisualization.ipynb

More Repositories

1

tts-cgan

TTS-CGAN: A Transformer Time-Series Conditional GAN for Biosignal Data Augmentation
Jupyter Notebook
60
star
2

eeg-transfer-learning

Source code for self-supervised EEG data transfer learning
Jupyter Notebook
13
star
3

recurrence-with-self-attention

The repository contains source code and data from the paper titled "Recurrence and Self-Attention vs the Transformer for Time-Series Classification: A Comparative Study".
Python
13
star
4

load_data_time_series

Generate numpy arrays for classification tasks from public datasets
Jupyter Notebook
9
star
5

biodiffusion

Python
7
star
6

identifying_label_noise

Python
4
star
7

biosignal_analysis_tutorials

This repository hosts various examples of human biosignal analysis.
Jupyter Notebook
4
star
8

TSAR

Python
2
star
9

multi-output-psg

Predicting Cardiac and Respiratory Events in the PSG-Audio Dataset
Jupyter Notebook
2
star
10

time-series-label-assist

A Python-based labeling tool that uses self-supervised learning and visualizations to assist humans in labeling time series data
Jupyter Notebook
2
star
11

fusion-of-learned-representations

Code repository for paper: Fusion of Learned Representations for Multimodal Sensor Data Classification
Jupyter Notebook
2
star
12

BioSGAN

Jupyter Notebook
1
star
13

BioDiffusion_dev

BioDiffusion paper source code and docs using a template repo
Jupyter Notebook
1
star
14

NNCLR_feature_learning

Python
1
star
15

model_evaluation_for_HAR

Source files for Model Evaluation Approaches to Human Activity Recognition from Time-Series Data to be presented at AIME2021
Jupyter Notebook
1
star
16

CL_Clean

Jupyter Notebook
1
star
17

covid19-hospital-and-icu-length-of-stay

Repository for paper "Predicting ICU and Hospital Length of Stay for COVID-19 Patients"
Jupyter Notebook
1
star
18

SmoothConditionalDiffusion

Python
1
star
19

TimeSeriesNNCLR

Jupyter Notebook
1
star