Problem with LSTM Time Prediction of a sinus curve

Hi Everyone,
i really hope you guys can help me out with my problem. For my Master Thesis i want to program a LSTM that predicts the remaining Life Time of a mechanical part, by using time/vibration signals as input. To get a feeling for LSTM’s i’m trying to train one to predict a sine curve.

This here is My Code. My model doesn’t train very well hence the predictions are bad as well. The loss starts at 0.5 and decreases really fast after just 3 epochs. I tried tried the multi-one approach, where my input is a seq_len tensor and my output is the one next value after the sequence.

I’d tried so many configurations; Added LSTM layers, changed the hidden size in a range of 2-500,
tried a lr from e-06 - e-03, tried different Sequence length and batch sizes, used different optimizer, but it seems like nothing really works.

Does anyone have a idea what i can try, or does anyone see a mistake in my code? I would be really happy if someone could help me :slight_smile:

My latest tries look like this:
Output while training

Hello there)

Don’t know, if its still important, but I’ve noticed, that you’ve used shuffle:

    trainloader = DataLoader(Trainingset, batch_size, shuffle = True, drop_last=True, num_workers=0)
    validloader = DataLoader(Validationset, batch_size, shuffle = True, drop_last=True, num_workers=0)

For LSTM order is important, and by using shuffle you’ve confused LSTM. I’ve changed shuffle to False and it works okay.

1 Like