模型开发接口
推理部署接口
API 相关说明
Performs one-hot encoding for the input tensor.
inp (Tensor) – input tensor.
Tensor
num_classes (int) – number of classes denotes the last dimension of the output tensor.
int
Examples
>>> import numpy as np >>> x = Tensor(np.arange(1, 4, dtype=np.int32)) >>> F.one_hot(x, num_classes=4) Tensor([[0 1 0 0] [0 0 1 0] [0 0 0 1]], dtype=int32, device=xpux:0)
previous
megengine.functional.nn.dropout
next
megengine.functional.nn.indexing_one_hot