ConstantInitializer_cn.rst 713 字节
Newer Older
H
Hao Wang 已提交
1 2 3 4 5 6 7
.. _cn_api_fluid_initializer_ConstantInitializer:

ConstantInitializer
-------------------------------

.. py:class:: paddle.fluid.initializer.ConstantInitializer(value=0.0, force_cpu=False)

8
该接口为常量初始化函数,用于权重初始化,通过输入的value值初始化输入变量;
H
Hao Wang 已提交
9 10

参数:
11 12 13 14
        - **value** (float16|float32) - 用于初始化输入变量的值;

返回:对象

H
Hao Wang 已提交
15 16 17
**代码示例**

.. code-block:: python
18

H
Hao Wang 已提交
19 20 21
        import paddle.fluid as fluid
        x = fluid.layers.data(name="data", shape=[32, 32], dtype="float32")
        fc = fluid.layers.fc(input=x, size=10,
22
            param_attr=fluid.initializer.ConstantInitializer(value=2.0))
H
Hao Wang 已提交
23 24 25 26 27 28