4 - Reshaping train and test data for Keras - Keras.layers.LSTM( ) input_shape explained

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ธ.ค. 2024
  • In this video, we learn how to prepare /reshape the test and train data to what Keras LSTM layer expects - [batch, timesteps, features]

ความคิดเห็น • 28

  • @djerradabderrahim
    @djerradabderrahim ปีที่แล้ว

    Even among the millions of videos on TH-cam, some videos stand out like yours. Really interesting and easy to understand video.

  • @Sunnyccccchhhhhhhh
    @Sunnyccccchhhhhhhh ปีที่แล้ว

    Clear, simple, nice interpretation

  • @hyperbrug9328
    @hyperbrug9328 ปีที่แล้ว

    Thank you so much. It was so confusing for me until this video.

  • @zacharyknepp927
    @zacharyknepp927 ปีที่แล้ว

    This helped me so much. Perfect explanation

  • @djaberomarkahlouche6342
    @djaberomarkahlouche6342 2 ปีที่แล้ว +1

    Ty for Ur vidéo , i was struggling for three days in this . Thnx for Ur explication

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว

      I hear you. The struggle is real! I am glad the video was helpful.

  • @mykewl5406
    @mykewl5406 2 ปีที่แล้ว

    Incredibly informative and perfectly succinct!

  • @aesthetic_GIRlie1347
    @aesthetic_GIRlie1347 2 ปีที่แล้ว

    This was very good. Thanks a lot for the good explanation.

  • @psychedelatry
    @psychedelatry 2 ปีที่แล้ว

    Thanks, this was exactly what I was looking for. Great explanation!

  • @SaifAbbas-c9p
    @SaifAbbas-c9p 5 หลายเดือนก่อน

    clear thanks

  • @outroutono4937
    @outroutono4937 ปีที่แล้ว

    Thank you!

  • @vishnuppriya5263
    @vishnuppriya5263 ปีที่แล้ว

    Thank you for this great explanation with example tabulated values mam. I am having 84 number of samples and 17 features for each sample to do binary classification problem. Now there is no multiple timesteps for feature calculation. So, in this case my input may be reshaped as (84, 1, 17) (i.e. batch size=84 whole samples are batched as one batch, time step=1,features=17). Wheather this is correct?Can i work lstm model for my binary classification problem?

  • @mohammednurulislam2132
    @mohammednurulislam2132 2 ปีที่แล้ว +1

    Hi, I would like to thank you for the way you explained it in this video. Also, I would be glad to know how I can reshape my custom 2D image dataset for the LSTM model. For my project (binary image classification), I would like to apply only LSTM first, and then I will try a combination of LSTM and CNN. Advanced thanks :)

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว +1

      @Mohammed, Thank you for the feedback! Tensorflow documentation has an example of using image data (MNIST) for the LSTM model. I believe this example will be of help to you - www.tensorflow.org/guide/keras/rnn.
      Specifically, this is how the image is treated for the LSTM model... An excerpt from the Tensorflow documentation, " We'll use as input sequences the sequence of rows of MNIST digits (treating each row of pixels as a timestep), and we'll predict the digit's label."
      Please let me know if this does not help. Good luck! Thanks.

    • @mohammednurulislam2132
      @mohammednurulislam2132 2 ปีที่แล้ว

      @@prabhjotgosal2489 Thank you for responding. I went through the tutorials which used MNIST datasets, and I got some intuition on how to build LSTM with Grayscale images. But for my custom model, I am struggling with how I can feed my RGB images as input layers. I am sorry for asking but I can't figure out how to solve this. Thanks

  • @folashadeolaitan6222
    @folashadeolaitan6222 2 ปีที่แล้ว

    Hi @Prabhjot thank you for this video. Pls i would like to know, do u reshape before normalizing and splitting your data or after?

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว

      @Folashade, you are welcome! In my case, I reshaped before normalizing because the normalization was done as part of my LSTM model. Also, I reshaped after the test/train split. In my opinion, it should not matter (in terms of the model performance) if we reshape before or after the test split.

    • @folashadeolaitan6222
      @folashadeolaitan6222 2 ปีที่แล้ว

      @@prabhjotgosal2489 Thank you for your response. Pls how can i connect with you urgently. I have an LSTM model i am working on and having some small challenges with. Pls help.

  • @krishnabahadurthapa6571
    @krishnabahadurthapa6571 2 ปีที่แล้ว

    Hi, I would be glad to know how I can reshape my 1D numerical dataset for the LSTM model. For my project (binary classification), I would like to apply only LSTM first, and then I will try a combination of LSTM and Bayesian Neural Network.

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว +1

      Hi, When you say, your dataset is 1D, I assume each sample in the dataset is 1-dimensional of size M. If that is the case, then the problem is similar to the first example in this video. You can use numpy.reshape() function to reshape the dataset into a [batch, timestep, feature] assuming your dataset shape is NXM , where N is the total number of samples in the dataset and M is the size of each of the 1D numerical data. I suggest watch the video between 1:56 - 5:32mins.

  • @TPLCompany
    @TPLCompany ปีที่แล้ว

    I am trying to train a LSTM model that has different shape of input and output. My input's shape is (N, 5, 2) and my output shape is (M, 3, 2). Is this possible? I am having a problem with the output shape not being the same as input shape.
    many thanks.

  • @arunabhgoswami6293
    @arunabhgoswami6293 2 ปีที่แล้ว

    @Prabhjot Gosal Could you please explain what should be the input shape for the LSTM model if I have text data transformed to tf-idf of shape 1000 x 200?

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว

      @Arunabh Goswami, I have not used LSTMs for text data before. So, please take my suggestion with a grain of salt...... Here is what I would try. Assuming 1000 is the total number of documents and 200 is the total number of words across those documents, we have 1000x200 entries containing TF-IDF for those words. Therefore, the last dimension for the LSTM should be 1 (because we have just one feature, which is the TF-IDF per entry). So, I would reshape the data first to [1000x200x1]. This corresponds to what the LSTM is expecting [batch size, time steps, features]. The first dimension is number of samples to be fed to the model per batch if you are sending data in batches. This can se set equal to the total number of samples as well. The last dimension is the feature dimension, which is 1 in this case. The second dimension that LSTM is expecting is time steps (typically used for time series data). In this case, we do not have a time series data, so, we use number of words. Note, depending upon how you create the model, you will need to adjust the Input_shape to (200x1). . . .Let me know if this works.

  • @AnimationsJungle
    @AnimationsJungle 2 ปีที่แล้ว

    What if the input size is 25000 * 4 ....with one feature ....should i give input size 4,25000,1... doesn't make sense ??
    How we use window size ... please clearify ....thank you

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว

      Can you please clarify, what are 25000 and 4? 25000 is seem like really big number for it to be number of timesteps. The format for LSTM input is [batch size, time steps, features]. I think you got the last dimension correct if you only have one feature per input. I would be able to help more if you could clarify what the input exactly is? Is it a time series data with 25000 time steps?

    • @AnimationsJungle
      @AnimationsJungle 2 ปีที่แล้ว

      @@prabhjotgosal2489 yes mam ...25000 are the time steps and 4 is my dimension .... Kindly help

    • @prabhjotgosal2489
      @prabhjotgosal2489  2 ปีที่แล้ว +2

      @@AnimationsJungle Then it sounds like 4 is the dimension of the features (number of features at each time step)? I would suggest watching the video again. The example at 5:40 sec mark may be helpful to reshape the data first if it is not already reshaped before feeding into the LSTM. I am a little weary of telling exactly what to do as I am not fully aware of your exact problem and would hate to direct you in a wrong direction.

    • @AnimationsJungle
      @AnimationsJungle 2 ปีที่แล้ว

      @@prabhjotgosal2489 can i get your contact so i can discuss it more.....