0
$\begingroup$

I’m implementing an LSTM with Keras and I know that I have to reshape the training dataset in a 3D object. Basically I have a dataset of shape (300000, 839)and I reshape it as (100000, 3, 839) because I want a timestep of 3. The question is: how could I treat the training set labels? Have I to reshape also them? if I reshape the labels to 100000, I don't truncate 200000 labels, since the starting number of labels is 300000?

Thanks in advance.

$\endgroup$
0
$\begingroup$

Your approch so far is not exactly right. Assuming you want to use the many to one approcah, the way you do it is as follows:

You have a dataset like this:

enter image description here

And you prepare your data in a way like this:

enter image description here

Source

For a timestep of 3, you discard the first 2 occurrences of your labels and use $y_{3}$ for the inputs $\{x_1, x_2,x_3\}$.

Next you don't start in $x_4$. Instead you use the next three-item slice $\{x_2, x_3, x_4\}$ with the training label $y_4$.

You continue this way until the last imput $\{x_{n-2}, x_{n-1}, x_{n}\}$ to predict $y_n$. If you have $n=30000$ samples, you can generate up to $n-2$ (29998) training samples for your model following this logic.

| improve this answer | |
$\endgroup$
  • $\begingroup$ ’s thank you for the asnwer. So my model predictions will be 29998 labels? $\endgroup$ – pairon Feb 28 at 12:18
  • $\begingroup$ As fas as I understand what you want to do, yes $\endgroup$ – TitoOrt Feb 28 at 12:22
  • $\begingroup$ my task is to predict the correct words order given an unordered sentence. So, my dataset is a list of words (I could reshape the dataset in a 3D shape into a set of sentence, where each matrix of data is the set of words of the sentence). Optimally I would predict each word label, but if I have to truncate only the first 3 labels of the dataset (with timesteps=3) I think that is not a problem for the learning. What do you think about it? $\endgroup$ – pairon Feb 28 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.