parameters_to_vector

paddle.nn.utils. parameters_to_vector ( parameters, name=None ) [source]

Flatten parameters to a 1-D Tensor.

Parameters
  • parameters (Iterable[Tensor]) – Iterable Tensors that are trainable parameters of a Layer.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

A 1-D Tensor, which represents the parameters of a Layer.

Examples

>>> import paddle
>>> paddle.seed(2023)
>>> linear = paddle.nn.Linear(10, 15)

>>> t = paddle.nn.utils.parameters_to_vector(linear.parameters())
>>> print(t.shape)
[165]