Browse Source

fix(mge/functional): fix one_hot irregular coding style

tags/v1.7.2.m1
Asthestarsfalll 3 years ago
parent
commit
541bf3af29
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      imperative/python/megengine/functional/nn.py

+ 2
- 2
imperative/python/megengine/functional/nn.py View File

@@ -1587,8 +1587,8 @@ def one_hot(inp: Tensor, num_classes: int) -> Tensor:
[0 0 1 0]
[0 0 0 1]]
"""
zeros_tensor = zeros(list(inp.shape) + [num_classes], inp.dtype, inp.device)
ones_tensor = ones(list(inp.shape) + [1], inp.dtype, inp.device)
zeros_tensor = zeros(list(inp.shape) + [num_classes], dtype=inp.dtype, device=inp.device)
ones_tensor = ones(list(inp.shape) + [1], dtype=inp.dtype, device=inp.device)

op = builtin.IndexingSetOneHot(axis=inp.ndim)
(result,) = apply(op, zeros_tensor, inp, ones_tensor)


Loading…
Cancel
Save