create_tensor(dtype, name=None, persistable=False)
Create a variable, which will hold a Tensor with data type dtype.
dtype (string|numpy.dtype) – the data type of Tensor to be created, the data type is bool, float16, float32, float64, int8, int16, int32 and int64.
name (string, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name
persistable (bool) – Set the persistable flag of the create tensor. default value is False.
The tensor to be created according to dtype.
- Return type
import paddle.fluid as fluid tensor = fluid.layers.create_tensor(dtype='float32')