Skip to content

Commit 60b255b

Browse files
authored
Fix Constraint and StudentT model convert docs 易用性提升 (#6936)
1 parent 984b293 commit 60b255b

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.constraints.Constraint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ torch.distributions.constraints.Constraint()
1212
paddle.distribution.constraint.Constraint()
1313
```
1414

15-
两者功能一致,无参数,另外 `torch.distributions.constraints.Constraint` 对象使用 `check` 进行回调,而 `paddle.distribution.constraint.Constraint` 直接使用 `__call__`
15+
两者功能一致,无参数,对象均使用 `check` 进行回调。

docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.studentT.StudentT.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,3 @@ PyTorch 相比 Paddle 支持更多其他参数,具体如下:
2323
| loc | loc | 分布的均值位置, Pytorch 中,可为 float 或 Tensor 类型,但在 Paddle 中, loc 应与 df 同类型。 |
2424
| scale | scale | 分布的标准差的比例, Pytorch 中,可为 float 或 Tensor 类型,但在 Paddle 中, scale 应与 df 同类型。 |
2525
| validate_args | - | 是否添加验证环节。Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
26-
| 返回值 | 返回值 | 当 df 为 Tensor 时,pytorch 返回值维度与 df 相同,而 Paddle 不同,需转写。 |
27-
28-
### 转写示例
29-
30-
#### 返回值
31-
32-
```python
33-
# PyTorch 写法
34-
y = torch.distributions.studentT.StudentT(df=torch.tensor(3), loc=0.0, scale=1.0).sample()
35-
36-
# Paddle 写法
37-
x = paddle.to_tensor(3)
38-
loc = paddle.to_tensor(0.0)
39-
scale = paddle.to_tensor(1.0)
40-
y = paddle.distribution.StudentT(df=x, loc=loc, scale=scale).sample()
41-
y = paddle.reshape(y, x.shape)
42-
```

0 commit comments

Comments
 (0)