This function creates a tensor filled with ``fill_value`` which has identical shape of ``x`` and ``dtype``.
This function creates a tensor filled with `fill_value` which has identical shape and dtype
If the ``dtype`` is None, the data type of Tensor is same with ``x``.
with `input`.
Args:
Args:
x(Variable): The input tensor which specifies shape and data type. The data type can be bool, float16, float32, float64, int32, int64.
x(Tensor): The input tensor which specifies shape and data type. The data type can be bool, float16, float32, float64, int32, int64.
fill_value(bool|float|int|Variable): The value to fill the tensor with. Note: this value shouldn't exceed the range of the output data type.
fill_value(bool|float|int): The value to fill the tensor with. Note: this value shouldn't exceed the range of the output data type.
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of output. The data type can be one
dtype(np.dtype|core.VarDesc.VarType|str, optional): The data type of output. The data type can be one
of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
data type is the same as input.
data type is the same as input.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
Returns:
Returns:
out(Variable): The Tensor variable storing the output.
Tensor: Tensor which is created according to ``x``, ``fill_value`` and ``dtype``.
Raises:
Raises:
TypeError: The dtype must be one of bool, float16, float32, float64, int32, int64 and None.
TypeError: The data type of ``x`` must be one of bool, float16, float32, float64, int32, int64.
TypeError: The ``dtype`` must be one of bool, float16, float32, float64, int32, int64 and None.
The OP creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 1.
The OP creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 1.
Args:
Args:
shape(tuple|list|Variable): Shape of output tensor, the data type of shape is int32 or int64.
shape(tuple|list|Tensor): Shape of the Tensor to be created, the data type of shape is int32 or int64.
dtype(np.dtype|core.VarDesc.VarType|str, optional): Data type of output tensor, it supports
dtype(np.dtype|core.VarDesc.VarType|str, optional): Data type of output Tensor, it supports
bool, float16, float32, float64, int32 and int64. Default: if None, the data type is 'float32'.
bool, float16, float32, float64, int32 and int64. Default: if None, the data type is 'float32'.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
Returns:
Returns:
Variable: A tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 1.
Tensor: A tensor of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 1.
Raises:
Raises:
TypeError: The dtype must be one of bool, float16, float32, float64, int32, int64 and None
TypeError: The ``dtype`` must be one of bool, float16, float32, float64, int32, int64 and None
and the data type of out Tensor must be the same as the dtype.
and the data type of out Tensor must be the same as the dtype.
TypeError: The `shape` must be one of list, tuple and Variable.
TypeError: The ``shape`` must be one of list, tuple and Tensor. The data type of ``shape`` must