PyTorch Time Sequence Prediction With LSTM - Forecasting Tutorial

preview_player
Показать описание
In this Python Tutorial we do time sequence prediction in PyTorch using LSTMCells.

The neural network learns sine wave signals and tries to predict the signal values in the future.

Get my Free NumPy Handbook:

Code was taken and adapted from official examples repo:

Timeline:
00:00 - Intro
01:30 - Sine Wave Creation
06:30 - LSTM Model
15:50 - Training Loop
27:55 - Final Testing

~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

#Python #PyTorch

----------------------------------------------------------------------------------------------------------
* This is a sponsored link or an affiliate link. By clicking on it I may receive a provision (dependent on the link). You will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏
Рекомендации по теме
Комментарии
Автор

Finally a new PyTorch tutorial. I hope you enjoy it :)


* This is a sponsored link. You will not have any additional costs, instead you will support me and my project. Thank you so much for the support! 🙏

patloeber
Автор

Thank you for making this, I've been struggling with this stuff on and off for months. These videos on PyTorch made things click, I really appreciate you taking the time to make them. They've helped me immensly.

iEdp_
Автор

this is an amazing tutorial. thanks a lot for putting the effort. great job.

yunlongsong
Автор

Thank you, this is video helped me to understand how to use LSTM on Pytorch.

anaximeno
Автор

Amazing content! Although, quick question. I noticed you called 'self.hidden' at 29:48. However I didnt see a corresponding parameter to self.hidden i.e self.n_hidden has n_hidden parameters, while i cant see the number of parameters for self.hidden

scottk
Автор

Thank you so much. I found it very helpful!

LanTranLe-skcn
Автор

Hi Python Engineer, may I know how to do if we want to predict multiple steps instead of one step ahead? Hopefully you can show an example. thanks

cwumin
Автор

This is amazing! How do you always know exactly what I need and make a tutorial about it?
Any chance you could make a tutorial about how to make an estimator that can give out the width of the given sine function and the x-shift of the 3 sine functions relative to each other? That would quite literally save my life. I know it should be possible to do with a similar method employed in the video, but I just can't do it...

PWK
Автор

I am trying to run this code on my gpu. It should work, but it doesn't. device = torch.device("cuda" if torch.cuda.is_available() else "cpu") returns 'cuda', so my GPU is being detected. I also copied the training and test inputs and targets to the gpu with .to(device) as well as the model (model = But i still get the error: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat2 in method wrapper_CUDA_mm). It occurs in the optimizer step (optimizer.step(closure)). What do you think?

doctormaddix
Автор

Please make a video on the batch size, sequence length and input size and how they actually are fed to the machine

ansumandas
Автор

Is it better for prediction performance to pass the output of one LSTM to the next or to pass the previous hidden state (as done in the video)? I've seen both methods used and don't know which is better. Do you have any advice on when to use each approach?

JonasBalandraux
Автор

Hi, great video! Just want to ask, why do we have 2 Lstm cells, and not a single one? And not sure if I get it... in the forward() func we split samples by dim=1 to feed a sequence of elements right? So if target_inputs has say 1000 elements(columns in this case) it means, that our lstm knows what happened 1000 points behind and "use" all of them to make the very next prediction? Thanks!

grdev
Автор

idk i am a beginner and i use jupyter notebooks and i copied the code perfectly( after running no errors) but i did not get any predictions or loss ? any idea what must be the case?

rohanmenon
Автор

Hey! I was wondering why are there multiple colors at the end when at the start there was only 1 sine wave? I'm confused where all the additional red and green lines came from.
Thanks :)

regularviewer
Автор

Well explained. Please keep doing the great work that you are doing

maxmohamed
Автор

Can you do a video using Transformers for time series? Have not found anything useful on yt so far. Thanks and br

DanielWeikert
Автор

Hi. What method are you using to predict future samples? As I understand there are multiple methods

pietheijn-vogt
Автор

Thanks for the helpful video. Is the code on github? I didn't find it and it would be very helpful to play around a little bit

wollmonsterchen
Автор

your videos are amazing, thanks a lot 🙌

greatsaid
Автор

hey!! may i know why we are give x as input, (x.split), why not y.split??? because our sine wave is basically in variable y.

aimenmalik
join shbcf.ru