{"id":15646181,"url":"https://github.com/philipperemy/tensorflow-cnn-time-series","last_synced_at":"2025-04-30T11:54:17.168Z","repository":{"id":70249852,"uuid":"89427350","full_name":"philipperemy/tensorflow-cnn-time-series","owner":"philipperemy","description":"Feeding images of time series to Conv Nets! (Tensorflow + Keras)","archived":false,"fork":false,"pushed_at":"2017-04-27T07:48:02.000Z","size":321,"stargazers_count":49,"open_issues_count":0,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T15:51:14.408Z","etag":null,"topics":["cnn","convnet","convolutional-neural-networks","keras","recurrent-neural-networks","tensorflow","time-series"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philipperemy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-26T02:13:48.000Z","updated_at":"2024-08-12T19:29:24.000Z","dependencies_parsed_at":"2023-03-04T00:01:00.528Z","dependency_job_id":null,"html_url":"https://github.com/philipperemy/tensorflow-cnn-time-series","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Ftensorflow-cnn-time-series","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Ftensorflow-cnn-time-series/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Ftensorflow-cnn-time-series/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Ftensorflow-cnn-time-series/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipperemy","download_url":"https://codeload.github.com/philipperemy/tensorflow-cnn-time-series/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251694147,"owners_count":21628798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn","convnet","convolutional-neural-networks","keras","recurrent-neural-networks","tensorflow","time-series"],"created_at":"2024-10-03T12:11:43.101Z","updated_at":"2025-04-30T11:54:17.147Z","avatar_url":"https://github.com/philipperemy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using CNN on 2D Images of Time Series\nBecause too often time series are fed as 1-D vectors Recurrent Neural Networks (Simple RNN, LSTM, GRU..).\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eWill this time series go up or down in the next time frame?\u003c/b\u003e\u003cbr\u003e\n  \u003cimg src=\"fig/3.png\" width=\"400\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eWhich plot contains highly correlated time series?\u003c/b\u003e\u003cbr\u003e\n  \u003cimg src=\"fig/cor_uncor.png\" width=\"800\"\u003e\n\u003c/p\u003e\n\n## Possible advantages/drawbacks of such approach:\n\n### Advantages\n- Almost no pre-processing. Feed raw pixels (be careful of the resolution of the image though)!\n- We can add several time series on the same plot or on a different plot and concatenate both images.\n- Conv Nets have the reputation of being more stable than Recurrent Neural Networks for many tasks (WaveNet is just one example).\n- No vanishing/exploding gradient! Even though, it's less true with LSTM.\n\n### Drawbacks\n- Input is much bigger than feeding 1-D vectors. Actually it's very very sparse!\n- Training will be undoubtedly slower.\n- Sometimes it's also hard to train very big conv nets (VGG19 is such an example).\n\n\n## Let's get started!\n\n### Fake data generation\n```\ngit clone https://github.com/philipperemy/tensorflow-cnn-time-series.git\ncd tensorflow-cnn-time-series/\nsudo pip3 install -r requirements.txt\npython3 generate_data.py\n```\n\n### Start the training of the CNN (AlexNet is used here)\n```\npython3 alexnet_run.py\n```\n\n### Toy example: Binary classification of images of time series\n\nWe consider the following binary classification problem of time series:\n- *UP*: If the time series went up in the next time frame.\n- *DOWN*: if the time series went down.\n\nBecause 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:\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"fig/1.png\" width=\"400\"\u003e\u003cbr\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"fig/2.png\" width=\"400\"\u003e\u003cbr\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n### Keep in mind that LSTM is also good!\n```\npython3 lstm_keras.py # on correlation classification task\n[...]\n[test] loss= 0.021, acc= 100.00\n[test] loss= 0.004, acc= 100.00\n[test] loss= 0.004, acc= 100.00\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipperemy%2Ftensorflow-cnn-time-series","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipperemy%2Ftensorflow-cnn-time-series","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipperemy%2Ftensorflow-cnn-time-series/lists"}