Thank you very much, now I know where can I check when I have these type of problems. Despite the changes, it is still not working. I have seen that the problem lies in the output of the network. During the first epoch, the output tends to be really high. As a consequence, the difference between the target and the predicted output (in order to calculate the loss) usually tend to Nan when the difference is squared (MSE) but not when there is no quadratic component in the loss formula (as L1Loss).
Since the targets are normalized from -1 to 1 now, I think will try to implement a sigmoid function at the end to avoid high output values and see if it works.
Edit: well, I tried it and it didn’t go as expected, since the loss is totally constant during all the epochs.
Edit2: I changed the optimizer from SVG to Adam and this one seems to be working with MSELoss, so problem solved.