All Projects → proceduralia → Pytorch Gan Timeseries

proceduralia / Pytorch Gan Timeseries

GANs for time series generation in pytorch

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytorch Gan Timeseries

mtss-gan
MTSS-GAN: Multivariate Time Series Simulation with Generative Adversarial Networks (by @firmai)
Stars: ✭ 77 (-29.36%)
Mutual labels:  finance, time-series, generative-adversarial-network
Ad examples
A collection of anomaly detection methods (iid/point-based, graph and time series) including active learning for anomaly detection/discovery, bayesian rule-mining, description for diversity/explanation/interpretability. Analysis of incorporating label feedback with ensemble and tree-based detectors. Includes adversarial attacks with Graph Convolutional Network.
Stars: ✭ 641 (+488.07%)
Mutual labels:  time-series, lstm, generative-adversarial-network
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (-2.75%)
Mutual labels:  time-series, finance
Arch
ARCH models in Python
Stars: ✭ 660 (+505.5%)
Mutual labels:  time-series, finance
Deep Learning Time Series
List of papers, code and experiments using deep learning for time series forecasting
Stars: ✭ 796 (+630.28%)
Mutual labels:  time-series, lstm
Deep Learning Based Ecg Annotator
Annotation of ECG signals using deep learning, tensorflow’ Keras
Stars: ✭ 110 (+0.92%)
Mutual labels:  time-series, lstm
Telemanom
A framework for using LSTMs to detect anomalies in multivariate time series data. Includes spacecraft anomaly data and experiments from the Mars Science Laboratory and SMAP missions.
Stars: ✭ 589 (+440.37%)
Mutual labels:  time-series, lstm
Getting Things Done With Pytorch
Jupyter Notebook tutorials on solving real-world problems with Machine Learning & Deep Learning using PyTorch. Topics: Face detection with Detectron 2, Time Series anomaly detection with LSTM Autoencoders, Object Detection with YOLO v5, Build your first Neural Network, Time Series forecasting for Coronavirus daily cases, Sentiment Analysis with BERT.
Stars: ✭ 738 (+577.06%)
Mutual labels:  time-series, lstm
Flow Forecast
Deep learning PyTorch library for time series forecasting, classification, and anomaly detection (originally for flood forecasting).
Stars: ✭ 368 (+237.61%)
Mutual labels:  time-series, lstm
Fecon236
Tools for financial economics. Curated wrapper over Python ecosystem. Source code for fecon235 Jupyter notebooks.
Stars: ✭ 72 (-33.94%)
Mutual labels:  time-series, finance
Time Attention
Implementation of RNN for Time Series prediction from the paper https://arxiv.org/abs/1704.02971
Stars: ✭ 52 (-52.29%)
Mutual labels:  time-series, lstm
Numpy Ml
Machine learning, in numpy
Stars: ✭ 11,100 (+10083.49%)
Mutual labels:  lstm, wavenet
Quantmod
Quantitative Financial Modelling Framework
Stars: ✭ 578 (+430.28%)
Mutual labels:  time-series, finance
Multilabel Timeseries Classification With Lstm
Tensorflow implementation of paper: Learning to Diagnose with LSTM Recurrent Neural Networks.
Stars: ✭ 519 (+376.15%)
Mutual labels:  time-series, lstm
Tensorflow Lstm Regression
Sequence prediction using recurrent neural networks(LSTM) with TensorFlow
Stars: ✭ 433 (+297.25%)
Mutual labels:  time-series, lstm
Fecon235
Notebooks for financial economics. Keywords: Jupyter notebook pandas Federal Reserve FRED Ferbus GDP CPI PCE inflation unemployment wage income debt Case-Shiller housing asset portfolio equities SPX bonds TIPS rates currency FX euro EUR USD JPY yen XAU gold Brent WTI oil Holt-Winters time-series forecasting statistics econometrics
Stars: ✭ 708 (+549.54%)
Mutual labels:  time-series, finance
Doppelganger
[IMC 2020 (Best Paper Finalist)] Using GANs for Sharing Networked Time Series Data: Challenges, Initial Promise, and Open Questions
Stars: ✭ 97 (-11.01%)
Mutual labels:  time-series, generative-adversarial-network
Time Series Prediction
A collection of time series prediction methods: rnn, seq2seq, cnn, wavenet, transformer, unet, n-beats, gan, kalman-filter
Stars: ✭ 351 (+222.02%)
Mutual labels:  time-series, wavenet
Sdv
Synthetic Data Generation for tabular, relational and time series data.
Stars: ✭ 360 (+230.28%)
Mutual labels:  time-series, generative-adversarial-network
Msgarch
MSGARCH R Package
Stars: ✭ 51 (-53.21%)
Mutual labels:  time-series, finance

Financial time series generation using GANs

This repository contains the implementation of a GAN-based method for real-valued financial time series generation. See for instance Real-valued (Medical) Time Series Generation with Recurrent Conditional GANs.

Main features:

  • Causal Convolution or LSTM architectures for disciminator and generator
  • Non-saturing GAN training (see this tutorial for more info)
  • Generation can be unconditioned or conditioned on the difference between the last and the first element of the time series to be generated (i.e., a daily delta)
  • Conditional training done by supervised learning on the generator, either alternating optimization steps or combining adversarial and supervised loss

During conditional training, daily deltas that are given as additional input to the generator are sampled from a Gaussian distribution estimated from real data via maximum likelihood.

Some words on the dataset

Considering the original data provided in csv format, the values for the time series are obtained from the feature btp_price. Minimal preprocessing, including normalization in the range [-1,1], is done inside btp_dataset.py. The resulting dataset has 173 sequences of length 96, for an overall tensor shape of (173 x 96 x 1). If you use a dataset that is not compatible with this preprocessing, you can just write your own loader.

Project structure

The files and directories composing the project are:

  • main.py: runs the training. It can save the model checkpoints and images of generated time series, and features visualizations (loss, gradients) via tensorboard. Run python main.py -h to see all the options.
  • generate_dataset.py: generates a fake dataset using a trained generator. The path of the generator checkpoint and of the output *.npy file for the dataset must be passed as options. Optionally, the path of a file containing daily deltas (one per line) for conditioning the time series generation can be provided.
  • finetune_model.py: uses pure supervised training for finetuning a trained generator. Discouraged, it is generally better to train in supervised and unsupervised way jointly.
  • models/: directory containing the model architecture for both discriminator and generator.
  • utils.py: contains some utility functions. It also contains a DatasetGenerator class that is used for fake dataset generation.
  • main_cgan.py: runs training with standard conditional GANs. Cannot produce nice results, but it is kept for reference.

By default, during training, model weights are saved into the checkpoints/ directory, snapshots of generated series into images/ and tensorboard logs into log/.

Use:

tensorboard --logdir log

from inside the project directory to run tensoboard on the default port (6006).

Examples

Run training with recurrent generator and convolutional discriminator, conditioning generator on deltas and alternating adversarial and supervised optimization:

python main.py --dataset_path some_dataset.csv --delta_condition --gen_type lstm --dis_type cnn --alternate --run_tag cnn_dis_lstm_gen_alternte_my_first_trial

Generate fake dataset prova.npy using deltas contained in delta_trial.txt and model trained for 70 epochs:

python generate_dataset.py --delta_path delta_trial.txt --checkpoint_path checkpoints/cnn_conditioned_alternate1_netG_epoch_70.pth --output_path prova.npy

Finetune checkpoint of generator with supervised training:

python finetune_model.py --checkpoint checkpoints/cnn_dis_lstm_gen_noalt_new_netG_epoch_39.pth --output_path finetuned.pth

Insights and directions for improvement

  • As reported in several works in sequence generation using GANs, recurrent discriminators are usually less stable than convolutional discriminators. Thus, I recommend the convolution-based one.
  • I did not perform extensive search over hyperparameters and training procedures, being qualitative evaluation the only one easily possible. If a target task is configured (e.g., learning a policy), intuitions and quantitative evaluations can be obtained and used for selecting the best model.
  • There is a bit of a tradeoff between performance on realistic generation and error with respect to input delta. If having mild precision on the delta is not a problem for the final task, its error can be ignored; if one wants to reduce the error on the deltas as much as possible, it is possible either to weight the supervised objective more or to use the supervised fine tuning.
  • The training is sometimes prone to mode collapse: the current implementation could benefit from the use of recent GAN variations such as Wasserstein GANs. It would be sufficient to just change the adversarial part of the training.
  • The standard way to inject conditions in GANs cannot work without concern for the problem of generation conditioned by deltas: as I observed in some indepedent experiments, causal convolution-based neural networks are able to easily solve the problem of detecting the delta of a given sequence. Therefore, a discriminator that receives the delta as input can easily distinguish between real sequences with correct deltas and fake sequences with incorrect deltas.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].