# Why do regression LSTMs learn high to low inputs significantly better than low to high?

The specific problem I have is learning the relation $$x^2$$. I have an array of 0 through 19 (input values) and a target array of 0, 1, 4, 9, 16, 25, 36 and so on all the way up to $$19^2$$=361.

I have the following LSTM architecture:

1 input node
1 output node
32 hidden units


Now, interestingly, I accidentally trained my network wrong, in that I forgot to reverse the expected output list when training. So I trained the network for: $$0 \rightarrow 361 \\ 1 \rightarrow 324 \\ 2 \rightarrow 289 \\ 3 \rightarrow 256 \\ ... \\ 17 \rightarrow 4 \\ 18 \rightarrow 1 \\ 19 \rightarrow 0$$

Starting with a learning rate of 1 and halving it every 400 epochs, after 3000 epochs my error (which started somwhere in the millions) was 0.2.

However, when I went to correct this mistake, my error will hardly ever go beneath 100,000. Testing the network shows it does well in the low inputs, but once it starts to get to $$16^2$$ onwards, it really struggles to increase the output values past ~250.

I was just wondering if anyone has an explanation for this, as to why the LSTM struggles to learn to increase exponentially but seems to be able to learn to decrease exponentially just fine.

• I suspect that it is a problem with vanishing gradients, something like: If you feed in 19, you saturate the tanh in the LSTM, driving it to the regions where the gradient is almost 0, which is more hurtful when the target is 361 then when the target is 0 (since your output at the beginning is 0). But this is difficult to verify without having access to the model. Have you looked at the gradients in tensorboard? And could you post the mapping after training? I would also suggest to train the model again, but this time scale input and output to 0 to 1, and see if this observation still holds. – Luca Thiede Jan 14 at 10:03
• @LucaThiede That's a really good suggestion - it makes intuitive sense. I'll have to run the model again with scaled input/output. I'll try and create some form of visualisation of the gradients at each step – Recessive 19 hours ago
• @Recessive First LSTM shouldnt be used for this type of problem as its not temporal, second I ran this and got same loss for both ways (for me using MSE and same lr scheduler I get ~28000 loss), share your code and let us see if we can reproduce your behavior – mshlis 2 hours ago