mindspore.ParameterTuple
- class mindspore.ParameterTuple[source]
Inherited from tuple, ParameterTuple is used to save multiple parameter.
Note
It is used to store the parameters of the network into the parameter tuple collection.
Examples
>>> from mindspore import Tensor, Parameter, ParameterTuple >>> import numpy as np >>> x = Parameter(Tensor(np.array([[1, 2], [3, 4]], dtype=np.float32)), name="param") >>> y = Parameter(Tensor(np.array([[5, 6], [7, 8]], dtype=np.float32)), name="param1") >>> pt = ParameterTuple([x, y]) >>> pt1 = pt.clone(prefix="new")
- clone(prefix, init='same')[source]
Clone the parameters in ParameterTuple element-wisely to generate a new ParameterTuple.
- Parameters
prefix (str) – Namespace of parameter, the prefix string will be added to the names of parameters in parametertuple.
init (Union[Tensor, str, numbers.Number]) –
Clone the shape and dtype of Parameters in ParameterTuple and set data according to init. Default: ‘same’.
If init is a Tensor , set the new Parameter data to the input Tensor.
If init is numbers.Number , set the new Parameter data to the input number.
If init is a str, data will be set according to the initialization method of the same name in the Initializer.
If init is ‘same’, the new Parameter has the same value with the original Parameter.
- Returns
Tuple, the new Parameter tuple.
- Tutorial Examples: