Suppose I have a tensor `a`

with size of `(1, 1, 6, 6)`

```
print(a)
tensor([[[[0., 0., 0., 0., 0., 0.],
[0., 4., 4., 5., 5., 0.],
[0., 4., 4., 5., 5., 0.],
[0., 2., 2., 1., 1., 0.],
[0., 2., 2., 1., 1., 0.],
[0., 0., 0., 0., 0., 0.]]]])
```

and I have 5 classes in totall, is it possible to have one-hot encoding `b`

with size of `(1, 5, 6, 6)`

(without for loop if possible)

such that `0`

for empty so one-hot for label `0`

would be `[0, 0, 0, 0, 0]`

, and `1`

would be `[1, 0, 0, 0, 0]`

… `5`

would be `[0, 0, 0, 0, 1]`

, I tried to use `F.one_hot`

but cant get what I need. Thanks.

- the label should be
`0-4`

since 5 classes, but I have 0 specifically for empty space so I change the label to`1-5`

.