-
Notifications
You must be signed in to change notification settings - Fork 834
映射文档 No.70 #5860
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.70 #5860
Changes from 2 commits
80af80d
a97e61f
f2a649a
14f87f5
6b81149
ad00b30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## [ torch 参数更多 ]torch.nn.functional.mish | ||
|
||
### [torch.nn.functional.mish](https://pytorch.org/docs/1.13/generated/torch.nn.functional.mish.html?highlight=torch+nn+functional+mish#torch.nn.functional.mish) | ||
|
||
```python | ||
torch.nn.functional.mish(input, | ||
inplace=None) | ||
``` | ||
|
||
### [paddle.nn.functional.mish](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/functional/mish_cn.html) | ||
|
||
```python | ||
paddle.nn.functional.mish(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ torch 参数更多 ]torch.linalg.eig | ||
|
||
### [torch.linalg.eig](https://pytorch.org/docs/1.13/generated/torch.linalg.eig.html?highlight=torch+linalg+eig#torch.linalg.eig) | ||
|
||
```python | ||
torch.linalg.eig(A, | ||
out=None) | ||
``` | ||
|
||
### [paddle.linalg.eig](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/eig_cn.html) | ||
|
||
```python | ||
paddle.linalg.eig(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| A | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 tuple, Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.eig(t,out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.eig(t), y) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tuple 应该是不能通过paddle.assign()赋值,可以改为 torch.linalg.eig(t,out=(L, V))
L, V = paddle.linalg.eig(t) |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ torch 参数更多 ]torch.linalg.eigvals | ||
|
||
### [torch.linalg.eigvals](https://pytorch.org/docs/1.13/generated/torch.linalg.eigvals.html?highlight=torch+linalg+eigvals#torch.linalg.eigvals) | ||
|
||
```python | ||
torch.linalg.eigvals(A, | ||
out=None) | ||
``` | ||
|
||
### [paddle.linalg.eigvals](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/eigvals_cn.html) | ||
|
||
```python | ||
paddle.linalg.eigvals(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------------------------------------------- | | ||
| A | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.eigvals(t, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.eigvals(t), y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ torch 参数更多 ]torch.linalg.multi_dot | ||
|
||
### [torch.linalg.multi_dot](https://pytorch.org/docs/1.13/generated/torch.linalg.multi_dot.html?highlight=torch+linalg+multi_dot#torch.linalg.multi_dot) | ||
|
||
```python | ||
torch.linalg.multi_dot(tensors, | ||
out=None) | ||
``` | ||
|
||
### [paddle.linalg.multi_dot](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/multi_dot_cn.html) | ||
|
||
```python | ||
paddle.linalg.multi_dot(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| tensors | x | 表示输入的一个 tensor 列表 ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.multi_dot([[2,7], [1, 3]], out=y) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的输入也用 x 代替吧 |
||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.multi_dot([[2, 7], [1, 3]]), y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [ torch 参数更多 ]troch.nn.Mish | ||
|
||
### [troch.nn.Mish](https://pytorch.org/docs/1.13/generated/torch.nn.Mish.html?highlight=troch+nn+mish) | ||
|
||
```python | ||
troch.nn.Mish(inplace=False) | ||
``` | ||
|
||
### [paddle.nn.Mish](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Mish_cn.html) | ||
|
||
```python | ||
paddle.nn.Mish(name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| inplace | - | 表示在不更改变量的内存地址的情况下,直接修改变量的值,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里如果inplace=Fasle,可以写暂无转写方式,原地操作不能直接删除 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## [ torch 参数更多 ]torch.nanmean | ||
|
||
### [torch.nanmean](https://pytorch.org/docs/1.13/generated/torch.nanmean.html?highlight=nanmean#torch.nanmean) | ||
|
||
```python | ||
torch.nanmean(input, | ||
dim=None, | ||
keepdim=False, | ||
dtype=None, | ||
out=None) | ||
``` | ||
|
||
### [paddle.nanmean](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nanmean_cn.html) | ||
|
||
```python | ||
paddle.nanmean(x, | ||
axis=None, | ||
keepdim=False, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor,仅参数名不一致。 | | ||
| dim | axis | 表示进行运算的轴,可选项,仅参数名不一致。 | | ||
| keepdim | keepdim | 表示是否保留计算后的维度,可选项。 | | ||
| dtype | - | 指定输出数据类型,可选项,Pytorch 默认值为 None,Paddle 无此参数,需要转写。 | | ||
| out | - | 表示输出的 Tensor,可选项,Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### dytpe:指定数据类型 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.nanmean(x, dim=-1, dtype=torch.float32) | ||
|
||
# Paddle 写法 | ||
y = paddle.sparse.cast(x, value_dtype='float32') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里可以通过 y.astype()实现吗,可以的话这样就能写成一行 |
||
paddle.nanmean(y,dim=-1) | ||
``` | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.nanmean(t, dim=1,out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.nanmean(t, dim=1), y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## [ torch 参数更多 ]torch.take_along_dim | ||
|
||
### [torch.take_along_dim](https://pytorch.org/docs/1.13/generated/torch.take_along_dim.html?highlight=torch+take_along_dim#torch.take_along_dim) | ||
|
||
```python | ||
torch.take_along_dim(input, | ||
indices, | ||
dim, | ||
out=None) | ||
``` | ||
|
||
### [paddle.take_along_axis](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/take_along_axis_cn.html) | ||
|
||
```python | ||
paddle.take_along_axis(arr, | ||
indices, | ||
axis) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | arr | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| indices | indices | 表示索引矩阵 ,仅参数名不一致。 | | ||
| dim | axis | 表示沿着哪个维度获取对应的值,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.take_along_dim(t, idx, 1,out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.take_along_axis(t, idx, 1), y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ torch 参数更多 ]torch.special.erf | ||
|
||
### [torch.special.erf](https://pytorch.org/docs/1.13/special.html?highlight=torch+special+erf#torch.special.erf) | ||
|
||
```python | ||
torch.special.erf(input, | ||
out=None) | ||
``` | ||
|
||
### [paddle.erf](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/erf_cn.html) | ||
|
||
```python | ||
paddle.erf(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.special.erf(t, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.erf(t), 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.
这里的inplace不能直接删去,可以通过 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.
这里的inplace参数如果为True,则会在原地操作tensor,要想完全一致需要使用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.
已修改