Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc committed Dec 19, 2023
1 parent ae5a102 commit a3cdacf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## [仅参数名不一致]torch.nn.functional.pdist

### [torch.nn.functional.pdist](https://pytorch.org/docs/stable/generated/torch.nn.functional.pdist.html#torch.nn.functional.pdist)

```python
torch.nn.functional.pdist(input, p=2)
```

### [paddle.nn.functional.pdist](https://github.com/PaddlePaddle/Paddle/blob/210442ec30e5038809865a6105dd38308d1df2e0/python/paddle/nn/functional/distance.py#L111)

```python
paddle.nn.functional.pdist(x, p=2.0)
```

其中功能一致,仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------- |
| input | x | 输入的 Tensor,仅参数名不一致。 |
| p | p | 计算 p-norm 距离的 p 参数。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## [无参数]torch.Tensor.signbit

### [torch.Tensor.signbit](https://pytorch.org/docs/stable/generated/torch.Tensor.signbit.html#torch-signbit)

```python
torch.Tensor.signbit()
```

### [paddle.Tensor.signbit](https://github.com/PaddlePaddle/Paddle/blob/9ce3a54f456011c664c70fbcd318f2e1af0a7d81/python/paddle/tensor/math.py#L7175)

```python
paddle.Tensor.signbit()
```

两者功能一致,均无参数。
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## [torch 参数更多]torch.signbit

### [torch.signbit](https://pytorch.org/docs/stable/generated/torch.signbit.html#torch-signbit)

```python
torch.signbit(input, *, out=None)
```

### [paddle.signbit](https://github.com/PaddlePaddle/Paddle/blob/9ce3a54f456011c664c70fbcd318f2e1af0a7d81/python/paddle/tensor/math.py#L7175)

```python
paddle.signbit(x, name=None)
```

两者功能一致且参数用法一致,仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ---------------------------------------------- |
| input | x | 输入 Tensor,仅参数名不一致。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 |

### 转写示例

#### out:指定输出

```python
# Pytorch 写法
torch.signbit([1., 2., 3., -1.], out=y)

# Paddle 写法
paddle.assign(paddle.signbit([1., 2., 3., -1.]), y)
```

0 comments on commit a3cdacf

Please sign in to comment.