topk_acc

dragon.vm.torch.topk_acc(
  input,
  label,
  k,
  dim=None
)[source]

Compute the top-k accuracy according to the label.

If dim is not given, the last dimension of the input is chosen.

Parameters:
  • input (dragon.vm.torch.Tensor) – The input tensor.
  • label (dragon.vm.torch.Tensor) – The sparse label.
  • k (int, optional, default=1) – The top-K results to return.
  • dim (int, optional) – The axis of tensor to compute reduce value.
Returns:

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