未验证 提交 a75a9f95 编写于 作者: W wangchaochaohu 提交者: GitHub

fix fill_constant test=develop (#1497)

上级 2117932d
......@@ -5,19 +5,19 @@ fill_constant
.. py:function:: paddle.fluid.layers.fill_constant(shape,dtype,value,force_cpu=False,out=None)
该OP创建一个形状为shape并且数据类型为dtype的LoDTensor或者SelectedRows,同时用 ``value`` 中提供的常量初始化该LoDTensor或者SelectedRows
该OP创建一个形状为shape并且数据类型为dtype的Tensor,同时用 ``value`` 中提供的常量初始化该Tensor
创建的LoDTensor或者SelectedRows的stop_gradient属性默认为True。
创建的Tensor的stop_gradient属性默认为True。
参数:
- **shape** (tuple|list)- 创建LoDTensor或者SelectedRows的形状。
- **shape** (tuple|list)- 创建Tensor的形状。
- **dtype** (np.dtype|core.VarDesc.VarType|str)- 创建LoDTensor或者SelectedRows的数据类型,支持数据类型为float16, float32, float64, int32, int64。
- **value** (float|int)- 用于初始化输出LoDTensor或者SelectedRows的常量数据的值。
- **force_cpu** (bool)- 用于标志LoDTensor或者SelectedRows是否创建在CPU上,默认值为False,若设为true,则数据必须在CPU上。
- **out** (Variable,可选)- 用于存储创建的LoDTensor或者SelectedRows,可以是程序中已经创建的任何Variable。默认值为None,此时将创建新的Variable来保存输出结果。
返回: 根据shape和dtype创建的LoDTensor或者SelectedRows
返回: 根据shape和dtype创建的Tensor
返回类型:变量(Variable)
......@@ -26,5 +26,6 @@ fill_constant
.. code-block:: python
import paddle.fluid as fluid
data1 = fluid.layers.fill_constant(shape=[1], value=0, dtype='int64') #data1=[0]
data2 = fluid.layers.fill_constant(shape=[1], value=5, dtype='int64', out=data1) #data1=[5] data2=[5]
data1 = fluid.layers.fill_constant(shape=[2,1], value=0, dtype='int64') #data1=[[0],[0]]
data2 = fluid.layers.fill_constant(shape=[2,1], value=5, dtype='int64', out=data1)
#data1=[[5],[5]] data2=[[5],[5]]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册