Multivariate Time Series Classification Tutorial with LSTM in PyTorch, PyTorch Lightning and Python
Вставка
- Опубліковано 3 сер 2024
- 🎓 Prepare for the Machine Learning interview: mlexpert.io
🔔 Subscribe: bit.ly/venelin-subscribe
📖 Get SH*T Done with PyTorch Book: bit.ly/gtd-with-pytorch
🗓️ 1:1 Consultation Session With Me: calendly.com/venelin-valkov/c...
🔣 GitHub: github.com/curiousily/Getting...
In this tutorial, you'll learn how to convert sequences of sensor data to classify the surface on which a robot currently is. We'll use PyTorch Lightning to build a data module and an LSTM model for sequence classification. How accurate will our model be?
#TimeSeries #PyTorch #Python #LSTM #Classification #Tutorial - Наука та технологія
You explained each step very clearly. Thanks man!
Thanks for the time spent, your video helped me getting me back into my project :]
I modified it to add evidence measure and evidence losses, thought not completely sure I'm doing everything ok and using it properly for inference / establishing the right rules to discriminate unreliable inferences, would be great if you could issue a part 2 adding that too.
Thank you for this great video!
Pleeease make some more videos about Time Series Forecasting!!
I would love to see them and to share them with friends.
regards from Austria
благодаря) този урок е страхотен
Great videos man, many thanks. Could you also provide the links for the source code.
Thanks for your great work 👍🏼
Nice tutorial, i like to see more such videos👍
Is it possible to teach some pytorch lightning in depth video?
Hi Venelin. I watched your forecasting and classification videos, both are useful and great. I wonder if I can do classification and forecast at the same time using the same dataset. Do you have any idea on this? thanks
Nice tutorial!
Thanks! can you share the notebook created here?
15:41: Making the PTL LightningDataModule.
20:04: Making the SequenceModel, which extends Pytorch nn.Module.
23:40: Making the PTL LightningModule.
Thanks for the great content. Why do you not normalize or standardize your data before feeding it into the LSTM?
Hey! Thanks for the tutorial!
What kind of techniques can we use for resampling time series classification data?
Can you please share some ideas?
Awesome video mate. Do you have one on timeseries classification with MLP?
Amazing thank you so much. Could you use transformers to handle same dataset
Thank you for the video. I have one question. Since you are using test_dataset for the validation loop. Will it not fit the model according to the test dataset? The model should not have any knowledge of the test dataset right.
Great video :)
ty!
Thank you for the insightful video! In this implementation we assume that all the instances in a sequence have the same label. What if the label of instances within a sequence are not the same and change within the sequence? How should we add the label information into the sequence?
Could you pls explain it using tensorflow?
Thanks for this tutorial. Could you please make a video of how to work with multi dimensional arrays as training data for the mode?
do u mean that each time series has e.g. 1 more dimension? how does this even make sense? which kind of time series has a shape like that ... and why would you not just instead make multiple time series from that one time series that has multiple dimensions?
How is it common to apply padding when the data length does not match?
Hey, is it not necessary to temporally split the data while creating training and testing data sets?
Hi, do you do the normalization before the modeling?
I'm getting this error:
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
Would you mind sharing the source code? That would help a lot
can we one-hot encode the categorical variables?
I am getting an error that 'SequenceModel' object has no attribute 'classifier'. Does anyone know why nn.Module doesn't have 'classifier' attribute?
Working Code:
github.com/ibadrather/pytorch_learn/blob/main/Part%2015%20-%20Multivariate_Time_%20Series_Classification_PyTorch_Lightning/Part%2015%20-%20Multivariate_Time_%20Series_Classification_Robot.ipynb
Thank you so much for the link. Unfortunately in your code, I guess there is an error. That's why in classification, All have been classified into concrete.
I have solved the problem. if you need it you can reply here.
@@asifsvirtualfootprint7370 Yes please share. I was thinking about this
@@asifsvirtualfootprint7370 Waiting for your reply :)
can we connect anyhow? I am doing a project with this code.
I followed your approach, took notes and am getting the following error when I try to initialize the SurfacePredictor
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 model = SurfacePredictor(
2 n_features = len(FEATURE_COLUMNS),
3 n_classes = len(label_encoder.classes_)
4 )
in __init__(self, n_features, n_classes)
5 def __init__(self, n_features: int, n_classes: int): # our constructor (int specifies featurs to integers)
6 super().__init__()
----> 7 self.model = SequenceModel(n_features, n_classes) # initialize the model by taking the number of features and classes
8 self.criterion = nn.CrossEntropyLoss() # criteria for classification
9
TypeError: __init__() takes 1 positional argument but 3 were given
Any thoughts on what I may be doing wrong?
In lstm don't we need to pass timestamp, n_features??
Superb work!
Looking forward to fine-tune Transformer BST/ BERT4REC
What happens when the sequence lengths are not the same? Say, for example, one was 128 and another was 130. What would you do in this case?
Undersample or oversample
@@amineleking9898 exactly?
@@user-yw6wf3uu1o for example add more points to the shortest sequence length to have same length as the other, using some technique. For example you can pad zeroes, or use linear interpolation....etc
You can interpolate them to a uniform frequency
I achieved loss=0.4251 and sparse_categorical_accuracy: 0.8596 for my 20% splitted testing data. Used tensorflow convolution network instead - it also works much better on Apple Silico. It only trained for 5 minutes or so then EarlyStopping kicked in. Btw there is like 10% of the code needed to do to with keras compared to torch.
Can you provide code please? :D
@@danielbalint8034 Think I've lost it. Just follow the official Tensorflow guide "Timeseries classification from scratch" instead. Btw i would be interested what results you've achieved :) I am wondering what transformers could do for this problem
Hi, are you planning to share the code with Github?
Hello, Venelin! Thank you for this! I followed all your code step-by-step, but I get this error:
RuntimeError: stack expects each tensor to be equal size, but got [0] at entry 0 and [1] at entry 3
What needs to be done to fix this?
Hi, I am facing same issue. Were you able to solve it?
same error here
same issue here, any fix?
same issue on my side as well
I had the same problem, I hope this will be helpful to others. The problem is in the __getitem__ function of the Dataset class, specifically in:
return dict(
sequence = torch.Tensor(sequence.to_numpy()),
label=torch.tensor(label).long()
)
where you have to be careful and see that for the label, tensor is with lowercase t
Don't work with CUDA 11.2 in google colab. Can update the code? thanks!
please update the video code. many part of the code have bugs now
Why you don't use one-hot encoding for preprocessing data?
I tried to install pytorch-lighting in Google Colab with no luck...Unfortunately your video is outdated
what error did you face ? You just need to run "!pip install pytorch-lightning"
you can't shuffle time series :)
А по-русски не проще было рассказать?
Thanks! can you share the notebook created here?