程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何通过pytorch有效地求解二次方程组? locuslab/qpth大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何通过pytorch有效地求解二次方程组? locuslab/qpth?

开发过程中遇到如何通过pytorch有效地求解二次方程组? locuslab/qpth的问题如何解决?下面主要结合日常开发的经验,给出你关于如何通过pytorch有效地求解二次方程组? locuslab/qpth的解决方法建议,希望对你解决如何通过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.solvetorch.linalg.solve)。但是你可以尝试例如:

locuslab/qpth

适用于 PyTorch 的快速且可微的 QP 求解器。

  • https://locuslab.github.io/qpth/

大佬总结

以上是大佬教程为你收集整理的如何通过pytorch有效地求解二次方程组? locuslab/qpth全部内容,希望文章能够帮你解决如何通过pytorch有效地求解二次方程组? locuslab/qpth所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:locuslab/qpth