-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ab186c
commit 33353dc
Showing
1 changed file
with
2 additions
and
22 deletions.
There are no files selected for viewing
24 changes: 2 additions & 22 deletions
24
...el_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.tensorinv.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,9 @@ | ||
## [组合替代实现]torch.linalg.tensorinv | ||
## [功能缺失]torch.linalg.tensorinv | ||
|
||
### [torch.linalg.inv](https://pytorch.org/docs/stable/generated/torch.linalg.tensorinv.html#torch-linalg-tensorinv) | ||
|
||
```python | ||
torch.linalg.tensorinv(A, ind=2, *, out=None) | ||
``` | ||
|
||
PaddlePaddle 目前无对应 API,可使用如下代码组合实现该 API。 | ||
|
||
## 转写示例 | ||
|
||
|
||
```python | ||
# PyTorch 写法: | ||
A = torch.eye(4 * 6).reshape((4, 6, 8, 3)) | ||
A_inv = torch.linalg.tensorinv(A, ind=2) | ||
|
||
# Paddle 转写: | ||
A = paddle.eye(4 * 6).reshape((4, 6, 8, 3)) | ||
ind = 2 | ||
A_dim_0 = prod(A.shape[ind:]) # 4 * 6 == 24 | ||
A_dim_1 = prod(A.shape[:ind]) # 8 * 3 == 24 | ||
# assert A_dim_0 == A_dim_1 | ||
A_ = paddle.reshape(A, [A_dim_0, A_dim_1]) | ||
A_inv_ = paddle.linalg.inv(A_) | ||
|
||
A_inv = paddle.reshape(A_inv_, A.shape[ind:] + A.shape[:ind]) | ||
``` | ||
PaddlePaddle 目前无对应 API。 |