The code is unreadable and long. Unless you format it and include proper comments, its very rare to receive an answer.



 ironmanaudi_leon:

self.B = Variable(torch.eye(self.cols), requires_grad = True) #关闭除对角线以外的求导
self.B_vec = Variable(torch.ones(self.cols, 1), requires_grad = True)
self.W_check = Variable((torch.ones(self.rows, self.rows) - torch.eye(self.rows)), requires_grad = True)#关闭对


I can only guess that you have to make these variables as nn.Parameter().