ConstantInitializer

  • class paddle.fluid.initializer.ConstantInitializer(value=0.0, force_cpu=False)[源代码]

该接口为常量初始化函数,用于权重初始化,通过输入的value值初始化输入变量;

  • 参数:
    • value (float16|float32) - 用于初始化输入变量的值;

返回:对象

代码示例

  1. import paddle.fluid as fluid
  2. x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
  3. fc = fluid.layers.fc(input=x, size=10,
  4. param_attr=fluid.initializer.ConstantInitializer(value=2.0))