大佬教程收集整理的这篇文章主要介绍了如何通过pytorch有效地求解二次方程组? locuslab/qpth,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要求解如下所示的非线性方程组:
def trySolveEquation(V,L):
#The equation to solve is:
#{ (V . Ct) ^ 2 = 1
#{ (L + u) . Ct = 0
#C and u are the unkNowns,C is a vector and u is a scalar,Ct is a vector transposed from C.
#V is a vector with dimension equal to Ct,L is a square matrix,they are kNown.
#u is Lagrange multiplIEr,and it's unkNown.
#'.' means matrix multiply.
dim = V.shape[0]
assert l.shape[0] == dim and l.shape[1] == dim
C = torch.zeros((dim))
Ct = C.vIEw((dim,1))
u = 0
'*Solve the equation here.*'
print('C=',C)
print('u=',u)
return C,u
C 的维数大约是 10,这个方程组最多可以求解 10 亿次,所以最好通过 Torch 实现,这样可以利用 GPU。还有比梯度下降更好的方法吗?
PyTorch 仅原生支持求解 线性 方程组(例如 torch.solve
、torch.linalg.solve
)。但是你可以尝试例如:
适用于 PyTorch 的快速且可微的 QP 求解器。
以上是大佬教程为你收集整理的如何通过pytorch有效地求解二次方程组? locuslab/qpth全部内容,希望文章能够帮你解决如何通过pytorch有效地求解二次方程组? locuslab/qpth所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。