create_parameter

paddle.static. create_parameter ( shape, dtype, name=None, attr=None, is_bias=False, default_initializer=None ) [source]
api_attr

Static Graph

This function creates a parameter. The parameter is a learnable variable, which can have gradient, and can be optimized.

NOTE: this is a very low-level API. This API is useful when you create operator by your self. instead of using layers.

Parameters
  • shape (list of int) – Shape of the parameter

  • dtype (str) – Data type of the parameter

  • name (str, optional) – For detailed information, please refer to Name . Usually name is no need to set and None by default.

  • attr (ParamAttr, optional) – Attributes of the parameter

  • is_bias (bool, optional) – This can affect which default initializer is chosen when default_initializer is None. If is_bias, initializer.Constant(0.0) will be used. Otherwise, Xavier() will be used.

  • default_initializer (Initializer, optional) – Initializer for the parameter

Returns

The created parameter.

Examples

import paddle
paddle.enable_static()
W = paddle.static.create_parameter(shape=[784, 200], dtype='float32')