What about my 2nd comment? Using the detach function will kill any gradients in your network which is most likely the explanation as to why it’s not learning.
Also could you indent your code by wrapping it in three backticks ``` , it makes it easier for people to read/copy!