Skip to content
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
## [ torch 参数更多 ]torch.Tensor.bernoulli
### [torch.Tensor.bernoulli](https://pytorch.org/docs/stable/generated/torch.Tensor.bernoulli.html#torch.Tensor.bernoulli)
## [ 仅参数名不一致 ]torch.Tensor.bernoulli
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的paconvert实现有点问题,这个数据是冗余的,这个仍然是 仅API调用方式不一致

infoflow 2025-10-23 19-42-35

后面有个地方要注意:就是paconvert数据可能不一定准确,你要注意自己看下api_difference是不是正确的,如果api_difference明显不对,那么说明paconvert可能是错的。paconvert的问题同样需要修复。


### [torch.Tensor.bernoulli](https://pytorch.org/docs/stable/tensors.html#torch.Tensor.bernoulli)

```python
torch.Tensor.bernoulli(p=None, *, generator=None)
torch.Tensor.bernoulli(*, generator=None)
```

### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bernoulli_cn.html#bernoulli)
### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bernoulli_cn.html#paddle/bernoulli_cn#cn-api-paddle-bernoulli)

```python
paddle.bernoulli(x, p=None, name=None)
paddle.bernoulli(x, name=None)
```

Pytorch 为 Tensor 类方法,Paddle 为普通函数,另外 PyTorch 相比 Paddle 支持更多其他参数。具体如下:

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

### 参数映射

Expand All @@ -19,14 +21,3 @@ Pytorch 为 Tensor 类方法,Paddle 为普通函数,另外 PyTorch 相比 Pa
| self | x | 伯努利参数 Tensor,将调用 torch.Tensor 类方法的 self Tensor 传入。 |
| p | p | 可选,伯努利参数 p。 |
| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |


### 转写示例
#### self:调用类方法的 Tensor
```python
# PyTorch 写法
x.bernoulli()

# Paddle 写法
paddle.bernoulli(x)
```
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
## [ 仅参数名不一致 ]torch.Tensor.hardshrink
### [torch.Tensor.hardshrink](https://pytorch.org/docs/stable/generated/torch.Tensor.hardshrink.html?highlight=torch+tensor+hardshrink#torch.Tensor.hardshrink)

### [torch.Tensor.hardshrink](https://pytorch.org/docs/stable/tensors.html#torch.Tensor.hardshrink)

```python
torch.Tensor.hardshrink(lambd=0.5)
```

### [paddle.nn.functional.hardshrink](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/hardshrink_cn.html#hardshrink)
### [paddle.nn.functional.hardshrink](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/hardshrink_cn.html#paddle/nn/functional/hardshrink_cn#cn-api-paddle-nn-functional-hardshrink)

```python
paddle.nn.functional.hardshrink(x, threshold=0.5, name=None)
```

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

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
|-----------------------------------|------------------------------| ------------------------------------------------------ |
| <font color='red'> lambd </font> | <font color='red'> threshold </font> | Hardshrink 阈值,仅参数名不一致 |
| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ----------------------------- |
| lambd | threshold | 阈值,仅参数名不一致,功能一致 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类方法改普通方法,统一在前面加一个

| self | x | (这个描述你想想怎么描述) |

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading