Thanks for the help! I clearly overlooked the possibility of different dimensions for output and target. I also realized the reason why learning was not taking place was that the LR was set at 0.1. Changing it to 0.001 leads to stable training.