-
Notifications
You must be signed in to change notification settings - Fork 724
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. 349/350 #6067
映射文档 No. 349/350 #6067
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6067.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
torch.Tensor.H也一起加进来吧,对应为:
|
torch.Tensor.mT | ||
``` | ||
|
||
Paddle 无此 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.
可以简述下转写思路原理
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 写法 | ||
perm = list(range(x.ndim)) | ||
perm[-1], perm[-2] = perm[-2], perm[-1] | ||
y = paddle.transpose(x, perm=perm) |
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.
可以用类方法来写:
x.transpose(perm=[0, 1, 3, 2])
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.
已修改
y = x.mT | ||
|
||
# Paddle 写法 | ||
perm = list(range(x.ndim)) |
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.
这个是自动转的写法,写人工转换思路时可以灵活直白些,比如假设为4D就直接写:
x.transpose(perm=[0, 1, 3, 2])
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.
已修改
y = x.mH | ||
|
||
# Paddle 写法 | ||
perm = list(range(x.ndim)) |
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.
可以用类方法来写,看起来更简洁:
x.transpose(perm=[0, 1, 3, 2]).conj()
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.Tensor.H |
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 |
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.
可以加一句,假设x为4D
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 无此 API,需要组合实现。 | ||
PyTorch 中等于 x.transpose(0, 1).conj(),Paddle 中 transpose 参数 perm 为转换后的维度位置 |
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仅针对2D
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 写法 | ||
y = x.mT | ||
|
||
# Paddle 写法 |
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.
可以加一句,假设x为4D
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
PaddlePaddle/PaConvert#112
349 torch.Tensor.mT 组合替代实现
350 torch.Tensor.mH 组合替代实现