Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

paddle.linalg.expm API

Open dongfangyixi opened this issue 4 years ago • 5 comments

请问paddle 预期什么时候实现 paddle.linalg.expm 这个api 等同于 scipy.linalg.expm 以及: torch.matrix_exp https://pytorch.org/docs/stable/generated/torch.matrix_exp.html

e的矩阵次方

或者动态图开放类似于 torch.autograd.Function 的功能,可以自己python定义op,不用写c再编译。

dongfangyixi avatar Oct 19 '21 14:10 dongfangyixi

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

paddle-bot-old[bot] avatar Oct 19 '21 14:10 paddle-bot-old[bot]

您好,您的反馈对产品非常有价值,我们内部会安排评估,未来有计划尽快回复。目前Paddle2.1及以上的动态图支持paddle.autograd.PyLayer你参考https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayer_cn.html#paddle.autograd.PyLayer 看下是否能实现torch.autograd.Function的功能。

wangxinxin08 avatar Oct 20 '21 02:10 wangxinxin08

可以试下 paddle.linalg.matrix_power 文档:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/matrix_power_cn.html 示例:

torch

x = torch.matrix_exp(torch.tensor([[2,0],[0,2]],dtype=torch.float)) x tensor([[7.3891, 0.0000], [0.0000, 7.3891]])

paddle

x = paddle.linalg.matrix_power(math.exp(1)*paddle.to_tensor([[1.,0],[0,1.]],dtype='float64'),n=2) x Tensor(shape=[2, 2], dtype=float64, place=CUDAPlace(0), stop_gradient=True, [[7.38905565, 0. ], [0. , 7.38905565]])

firestonelib avatar Dec 14 '21 13:12 firestonelib

@firestonelib 谢谢您的回答,用matrix power这个方法 对于对角或者可以对角化的矩阵应该可以的,但是对于一般的矩阵不行。 Pytorch 用了 "Bader, P.; Blanes, S.; Casas, F. Computing the Matrix Exponential with an Optimized Taylor Polynomial Approximation. Mathematics 2019, 7, 1174." 这个论文的算法。

这个应该是目前SOTA的matrix exponential的算法。

如果您有开发这个API的计划,我们可以更进一步进行一下细节上的交流。

@firestonelib Thank you. The matrix power api you mentioned is suitable in the case when the matrix is diagonal or diagnizable. But, it is not the solution for general cases.

In general, image

That is why torch implement the algorithm in the paper "Bader, P.; Blanes, S.; Casas, F. Computing the Matrix Exponential with an Optimized Taylor Polynomial Approximation. Mathematics 2019, 7, 1174."

Although there is a lot of algorithms to calcuate matrix exponential, it's seems like the Bader's paper is the state-of-the-art solution.

If you have a plan for this API, we can have a further discussion about the implemetaion details.

dongfangyixi avatar Dec 15 '21 08:12 dongfangyixi

You are very welcome to submit implementation of this API to us. You can refer to the requirements of the new API(such as rfc, code and docs) in our current Hackathon, and we can arrange experts to review and discuss.

jeff41404 avatar Aug 09 '22 09:08 jeff41404