megengine.functional.full¶
- full(shape, value, *, dtype=None, device=None)[源代码]¶
Returns a new tensor having a specified shape and filled with given value.
- 参数
shape (int...) – 输出张量的形状。
value (Scalar) – 填充值
- 关键字参数
dtype (
Tensor.dtype
, optional) – output tensor data type. Ifdtype
isNone
, the output tensor data type must be inferred fromvalue
. If the value is anint
, the output tensor data type must be the default integer data type. If the value is afloat
, the output tensor data type must be the default floating-point data type. If the value is abool
, the output tensor must have boolean data type.device (
Tensor.device
, optional) – device on which to place the created tensor.
- 返回类型
- 返回
一个全value的tensor
实际案例
>>> F.full((2, 3), 6) Tensor([[6 6 6] [6 6 6]], dtype=int32, device=xpux:0)