one_hot

    注意:此OP要求输入Tensor shape的最后一维必须为1。此OP将在未来的版本中被移除!推荐使用fluid. cn_api_fluid_one_hot 。

    该OP将输入(input)中的每个id转换为一个one-hot向量,其长度为 ,该id对应的向量维度上的值为1,其余维度的值为0。

    输出的Tensor(或LoDTensor)的shape是将输入shape的最后一维替换为depth的维度。

    • 示例1(allow_out_of_range=False):
    • 示例3 (allow_out_of_range=False):

    返回:转换后的one_hot Tensor或LoDTensor,数据类型为float32。

    返回类型:Variable