Denken
Menu
  • About Me
  • Deep Learning with Pytorch
  • Generative AI: Tutorial Series
  • Python Tutorials
  • Contact Me
Menu

Deep Learning with Pytorch -Sequence Modeling – Time Series Prediction – RNNs – 3.1

Posted on May 19, 2019May 19, 2019 by Aritra Sen

In the previous post of this series , we learnt about the intuition behind RNNs and we also tried to understood how we can use RNNs for sequential data like time series.In this post we will see a hands on implementation of RNNs in Pytorch.
In case of neural networks we feed a vector as predictors , however things are bit different in case of RNNs. Here the input to the model has to be a 3D array. Below are dimensions of this 3D array –
1. Number of samples or Batch Size – total number of training examples or batch size.
2. Sequence Length or Time Steps – RNN by definition is recurrent, it unrolls many times when you use it. It unrolls, in the sequence length dimension, as many times as items in your sequence. For example sequence length can be three if you trying to predict the next hour temperature using last three hours predictors as sequence.
3. Input Size – the usual no of features or predictors in your data.
Below is an example –

x = [ [[32,1383],[41,2928],[39,8823],[20,1252],[15,1532]],
[[35,8272],[32,1383],[41,2928],[39,8823],[20,1252]],
[[37,2738],[35,8272],[32,1383],[41,2928],[39,8823]],
[[34,2845],[37,2738],[35,8272],[32,1383],[41,2928]],
[[32,2345],[34,2845],[37,2738],[35,8272],[32,1383]], ]
Shape of this would be (5,5,2).

Below is an implementation of Multivariate Time Series Air pollution prediction of next hour given the predictor values. The idea and credit of this goes to the awesome blog post of Jason Brownlee
I have just converted his tutorial in Pytorch implementation.This is a dataset that reports on the weather and the level of pollution each hour for five years at the US embassy in Beijing, China. You can get the same dataset from this link as shared in the blog post by Jason Brownlee. Now let’s get our hands dirty.
Press up/down/right/left arrow to browse the below notebook.

Do like , share and comment if you have any questions.

Category: Machine Learning, Python

Post navigation

← Deep Learning with Pytorch -Sequence Modeling – Getting Started – RNN – 3.0
Deep Learning with Pytorch – Custom Weight Initialization – 1.5 →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RSS Feeds

Enter your email address:

Delivered by FeedBurner

Pages

  • About Me
  • Contact Me
  • Deep Learning with Pytorch
  • Generative AI: Tutorial Series
  • Python Tutorials

Tag Cloud

Announcements Anrdoid BERT Bias Celebration Cricket CyanogenMod deep-learning Denken Experience Facebook Features Finetuning GCN GenerativeAI GNN Google HBOOT HBOOT downgrading HTC Wildfire huggingface India Launch Life LLM Lumia 520 MachineLearning mobile My Space nlp Orkut People Python pytorch pytorch-geometric Rooting Sachin Share Social Network tranformers transformers Tutorials Twitter weight-initialization Windows Phone

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

Categories

Random Posts

  • Deep Learning with Pytorch -Sequence Modeling – LSTMs – 3.2
  • Deep Learning with Pytorch-CNN – Getting Started – 2.0
  • 1.2 – Fine Tune a Transformer Model (2/2)
  • Python Tutorials
  • Generative AI: LLMs: In Context Learning 1.2

Recent Comments

  • Generative AI: LLMs: Reduce Hallucinations with Retrieval-Augmented-Generation (RAG) 1.8 – Denken on Generative AI: LLMs: Semantic Search and Conversation Retrieval QA using Vector Store and LangChain 1.7
  • vikas on Domain Fuss
  • Kajal on Deep Learning with Pytorch -Text Generation – LSTMs – 3.3
  • Aritra Sen on Python Tutorials – 1.1 – Variables and Data Types
  • Aakash on Python Tutorials – 1.1 – Variables and Data Types

Visitors Count

AmazingCounters.com

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright

AritraSen’s site© This site has been protected from copyright by copyscape.Copying from this site is stricktly prohibited. Protected by Copyscape Original Content Validator
© 2025 Denken | Powered by Minimalist Blog WordPress Theme