[ 组合替代实现 ]torch.Tensor.requires_grad_
torch.Tensor.requires_grad_
torch.Tensor.requires_grad_(requires_grad=True)
paddle.Tensor.stop_gradient
paddle.Tensor.stop_gradient = False
两者功能一致,torch 为 function 调用方式,paddle 为 attribution 赋值方式,具体如下:
参数映射
| PyTorch | PaddlePaddle | 备注 |
|---|---|---|
| requires_grad | - | 是否计算梯度,Paddle 无此参数,需要转写。 |
