powered by
probs
logits
Creates a categorical distribution parameterized by either probs or logits (but not both).
distr_categorical(probs = NULL, logits = NULL, validate_args = NULL)
(Tensor): event probabilities
(Tensor): event log probabilities (unnormalized)
Additional arguments
if (torch_is_installed()) { m <- distr_categorical(torch_tensor(c(0.25, 0.25, 0.25, 0.25))) m$sample() # equal probability of 1,2,3,4 }
Run the code above in your browser using DataLab