Advanced Computing Platform for Theoretical Physics

commit大文件会使得服务器变得不稳定,请大家尽量只commit代码,不要commit大的文件。

Commit 59175136 authored by Pan Zhang's avatar Pan Zhang
Browse files

Merge branch 'master' of gitlab.theory.iphy.ac.cn:codes/playwithgrad

parents b9f4300c ca716f2a
'''
Three different ways of computing gradient of infinite matrix product trace
Different ways of computing gradient of infinite matrix product trace
Z = Tr(T*T...*T)
'''
......@@ -34,5 +34,9 @@ loss = torch.log(w[-1])
loss.backward()
exact_grad = ((T.grad + T.grad.t())/2) # need to symmetrize since it is an upper triangular matrix
# (4) use leading eigenvector of the transfer matrix $T$
eigenvector_grad= torch.ger(v[:,-1], v[:, -1])/w[-1] # outer product of the leading eigenvector and its transpose
print ((impurity_grad-exact_grad).abs().max().item())
print ((lnZ_grad-exact_grad).abs().max().item())
print ((eigenvector_grad-exact_grad).abs().max().item())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment