Everything in the second half (in the green box) is learning reliable weights but everything in the first half (blue box) is learning seemingly random weights. The backprop updates the weights and gradients of the first half, yet it is learning seemingly random weights that do not improve the training. The second half is learning correctly though.

Screenshot 2021-04-27 at 20.34.501252×468 64.9 KB

It seems the issue is something to do with the transpose/view function somehow causing the grad_fn function to be messed up. What exactly is the issue and how can it be fixed?