torch.Tensor.requires_grad¶ Tensor.requires_grad¶ 如果需要为此张量计算梯度,则使用 True ;否则使用 False 。 注意 对于 Tensor 需要计算梯度的事实并不意味着 grad 属性将被填充,有关更多详细信息,请参阅 is_leaf 。