Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddle.linalg.expm API #36563

Closed
dongfangyixi opened this issue Oct 19, 2021 · 5 comments
Closed

paddle.linalg.expm API #36563

dongfangyixi opened this issue Oct 19, 2021 · 5 comments
Labels
status/close 已关闭

Comments

@dongfangyixi
Copy link

请问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再编译。

@paddle-bot-old
Copy link

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网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!

@wangxinxin08
Copy link
Contributor

您好,您的反馈对产品非常有价值,我们内部会安排评估,未来有计划尽快回复。目前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的功能。

@firestonelib
Copy link
Contributor

可以试下 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]])

@dongfangyixi
Copy link
Author

@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.

@jeff41404
Copy link
Contributor

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.

@paddle-bot paddle-bot bot added the status/close 已关闭 label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/close 已关闭
Projects
None yet
Development

No branches or pull requests

4 participants