Solved by Yongjie_Shi in post #3 
              
              
                Thank you for your suggestions. Through step-by-step debugging, I found that the slow backpropagation was related to the large computational graph.  There are two places in the code that greatly extend the computational graph. The first is 
    center_x = center_x.unsqueeze(1)
    center_y = center_…