-
Notifications
You must be signed in to change notification settings - Fork 762
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
映射文档 No.48 #5840
映射文档 No.48 #5840
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-5840.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
映射任务列表48中的torch.matmul已经被其他贡献者提交; |
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> A </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> pivots </font> | <font color='red'> pivot </font> | 输入的 bool ,仅参数名不同。 | | ||
| <font color='red'> get_infos </font> | <font color='red'> get_infos </font> | 输入的 bool ,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里参数名是相同的~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
torch.lu(torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]), get_infos=True, out=(A_LU, pivots, info)) | ||
|
||
# Paddle 写法 | ||
lu, p, info = paddle.linalg.lu(paddle.to_tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]).astype('float64'), get_infos=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用paddle.assign实现赋值吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paddle.assign(x, output)中output为Tensor,此处assign会报TypeError: Unsupport paddle.assign([Variable, Variable...]) with non-scalar variable;
paddle.linalg.lu返回值为tuple,且tuple内Tensor维度不一致, 因此无法将结果转为list等方式拼接;
尚未找到合适赋值方式,暂未修改
| <font color='red'> LU_data </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> LU_pivots </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> unpack_data </font> | <font color='red'> unpack_ludata </font> | 输入的 bool ,仅参数名不同。 | | ||
| <font color='red'> unpack_pivots </font> | <font color='red'> unpack_pivots </font> | 输入的 bool ,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数名是一样的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
torch.lu_unpack(*torch.lu(torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])), out=(P, L, U)) | ||
|
||
# Paddle 写法 | ||
P,L,U = paddle.linalg.lu_unpack(*paddle.linalg.lu(paddle.to_tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]).astype('float64'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试一下可以用paddle.assign实现吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同paddle.linalg.lu
torch.matrix_power(torch.tensor([[1., 2., 3.],[1., 4., 9.],[1., 8., 27.]]), 2, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.matrix_power(paddle.to_tensor([[1, 2, 3],[1, 4, 9],[1, 8, 27]], dtype='float64'), 2), y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里paddle的写法中,可以将1换成 1. ,这样就不用显式写dtype了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
@@ -0,0 +1,30 @@ | |||
## [torch 参数更多 ]torch.matrix_rank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
签名和api名不一致~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| A | x | 输入的 Tensor ,仅参数名不同。 | | ||
| tol | tol | 输入的 Tensor 或者 float,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数名是一致的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
| ------------- | ------------ | ------------------------------------------------------ | | ||
| A | x | 输入的 Tensor ,仅参数名不同。 | | ||
| tol | tol | 输入的 Tensor 或者 float,仅参数名不同。 | | ||
| hermitian | hermitian | 输入的 bool ,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数名是一致的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已更正
@@ -0,0 +1,30 @@ | |||
## [torch 参数更多 ]torch.matrix_rank | |||
### [torch.matrix_rank](https://pytorch.org/docs/stable/generated/torch.linalg.matrix_rank.html?highlight=matrix_rank#torch.linalg.matrix_rank) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里少了linalg 吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原在线文档中该函数为torch.matrix_rank,pytorch1.13中实际只有torch.linalg.matrix_rank,已修改该api名及其文件名
torch.dot(torch.tensor([2, 3]), torch.tensor([2, 1]), out=y) | ||
|
||
# Paddle 写法 | ||
y = paddle.dot(paddle.to_tensor([2, 3]), paddle.to_tensor([2, 1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赋值可以用paddle.assign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| A | x | 输入的 Tensor ,仅参数名不同。 | | ||
| tol | tol | 输入的 Tensor 或者 float,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数名是一样的
@@ -0,0 +1,34 @@ | |||
## [torch 参数更多 ]torch.lu | |||
|
|||
### [torch.lu](https://pytorch.org/docs/stable/generated/torch.inverse.html?highlight=inverse#torch.inverse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
链接不正确
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 输入的 Tensor ,仅参数名不同。 | | ||
| n | n | 输入的 int ,仅参数名不同。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数名相同~
均已更正,并重新检查类似问题,确认无误 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦改一下
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.inner(torch.arange(1., 7.).reshape((2, 3)), torch.arange(1., 10.).reshape((3, 3)), out=y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面可以尽量把示例写的简单些,直接写list表示Tensor也行,这个本质是伪代码的形式让用户一眼看了就懂转换思路的。写出核心转换思路就可以,辅助运行的代码应省尽省。
torch.lu(torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]), get_infos=True, out=(A_LU, pivots, info)) | ||
|
||
# Paddle 写法 | ||
lu, p, info = paddle.linalg.lu(paddle.to_tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]), get_infos=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A_LU, pivots, info
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.ger(torch.arange(1., 5.), torch.arange(1., 4.), out=y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写的比较复杂,建议写简略一些
已修改相关样例表示 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
hi, @YiZoey
|
分组 ID 48