megengine.functional.full

full(shape, value, dtype='float32', device=None)[源代码]

Creates a tensor of shape shape filled with value.

参数
  • shape – a list, tuple or integer defining the shape of the output tensor.

  • value – the value to fill the output tensor with.

  • dtype – the desired data type of the output tensor. Default: float32.

  • device – the desired device of the output tensor. Default: if None, use the default device(see megengine.get_default_device()).

返回类型

Tensor

返回

output tensor.

Examples:

import numpy as np
import megengine.functional as F

out = F.full([2,3], 1.5)
print(out.numpy())

Outputs:

[[1.5 1.5 1.5]
 [1.5 1.5 1.5]]