mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
`torch.nn.functional.one_hot` [document](https://pytorch.org/docs/stable/generated/torch.nn.functional.one_hot.html) describe param `num_classes` not optional, but user can call method without pass it.

```python
>>> import torch
>>> a = torch.arange(0, 5) % 3 # [0,1,2,0,1]
>>> torch.nn.functional.one_hot(a)
tensor([[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[1, 0, 0],
[0, 1, 0]])
```
`num_classes` has default value -1
|
||
|---|---|---|
| .. | ||
| attention | ||
| backends | ||
| intrinsic | ||
| modules | ||
| parallel | ||
| qat | ||
| quantizable | ||
| quantized | ||
| utils | ||
| __init__.py | ||
| _reduction.py | ||
| common_types.py | ||
| cpp.py | ||
| functional.py | ||
| functional.pyi.in | ||
| grad.py | ||
| init.py | ||
| parameter.py | ||
| parameter.pyi | ||