megengine.functional.full_like

full_like(inp, value)[源代码]

返回一个与输入张量形状相同的且值为给定值的零张量

参数
返回类型

Union[Tensor, SymbolVar]

返回

output tensor.

Examples: .. testcode:

import numpy as np
from megengine import tensor
import megengine.functional as F

inp = tensor(np.arange(1, 7, dtype=np.int32).reshape(2,3))
out = F.full_like(inp, 2)
print(out.numpy())

Outputs:

[[2 2 2]
 [2 2 2]]