one_hot

dragon.vm.torch.nn.functional.one_hot(
  tensor,
  num_classes,
  on_value=1,
  off_value=0
)[source]

Return the one-hot representation of input.

Parameters:
  • tensor (dragon.vm.torch.Tensor) – The input tensor.
  • num_classes (int) – The number of classes.
  • on_value (number, optional, default=1) – The value for equal branch.
  • off_value (number, optional, default=0) – The value for not-equal branch.
Returns:

dragon.vm.torch.Tensor – The output tensor.