Giter VIP home page Giter VIP logo

tensorflow-cnn-time-series's Introduction

Using CNN on 2D Images of Time Series

Because too often time series are fed as 1-D vectors Recurrent Neural Networks (Simple RNN, LSTM, GRU..).

Will this time series go up or down in the next time frame?

Which plot contains highly correlated time series?

Possible advantages/drawbacks of such approach:

Advantages

  • Almost no pre-processing. Feed raw pixels (be careful of the resolution of the image though)!
  • We can add several time series on the same plot or on a different plot and concatenate both images.
  • Conv Nets have the reputation of being more stable than Recurrent Neural Networks for many tasks (WaveNet is just one example).
  • No vanishing/exploding gradient! Even though, it's less true with LSTM.

Drawbacks

  • Input is much bigger than feeding 1-D vectors. Actually it's very very sparse!
  • Training will be undoubtedly slower.
  • Sometimes it's also hard to train very big conv nets (VGG19 is such an example).

Let's get started!

Fake data generation

git clone https://github.com/philipperemy/tensorflow-cnn-time-series.git
cd tensorflow-cnn-time-series/
sudo pip3 install -r requirements.txt
python3 generate_data.py

Start the training of the CNN (AlexNet is used here)

python3 alexnet_run.py

Toy example: Binary classification of images of time series

We consider the following binary classification problem of time series:

  • UP: If the time series went up in the next time frame.
  • DOWN: if the time series went down.

Because it's impossible to classify pure random time series into two distinct classes, we expect a 50% accuracy on the testing set and the model to overfit on the training set. Here are some examples that we feed to the conv net:





Keep in mind that LSTM is also good!

python3 lstm_keras.py # on correlation classification task
[...]
[test] loss= 0.021, acc= 100.00
[test] loss= 0.004, acc= 100.00
[test] loss= 0.004, acc= 100.00

tensorflow-cnn-time-series's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.