Parameter
- class paddle.nn. Parameter ( data: Tensor | None = None, requires_grad: bool = True ) [source]
-
Parameter is a subclass of Tensor, which is a persistable Tensor that can be updated by optimizers during training.
- Parameters
-
data (Tensor, optional) – The initial data for the Parameter. If None, an empty Tensor will be created. Default: None.
requires_grad (bool, optional) – Whether this Parameter requires gradient computation. If True, the Parameter will accumulate gradients during backward pass. Default: True.
Examples
>>> import paddle >>> # Create a Parameter from existing Tensor >>> weight = paddle.to_tensor([1.0, 2.0, 3.0]) >>> param = paddle.nn.Parameter(weight) >>> print(param) >>> # Create a Parameter without initial data >>> param = paddle.nn.Parameter() >>> print(param)