ClikaRT::ops::multinomial
function
multinomial()
Tensor multinomial(
Tensor probabilities,
int64_t num_samples,
bool replacement = false,
StreamOrDevice s = {}
)
Categorical sampling: draws num_samples category indices per row of a weight tensor.
probabilities holds non-negative weights (they need not sum to 1), typically [batch, num_categories]; the output replaces the category axis with num_samples and is Int64. Without replacement each row samples distinct categories.
Parameters
probabilities: non-negative category weights[.., C].num_samples: draws per row; without replacement must be <=C.replacement: sample with replacement; default false.s: stream or device; default = the input's.
Returns: Int64 category indices, [.., num_samples].
Throws
ClikaRT::Error: (INVALID_ARGUMENT) when a weight is negative ornum_samplesexceedsCwithout replacement.
auto next = ClikaRT::ops::multinomial(probs, 1); // one token per row
Declared in ClikaRT/compute/ops.h, line 4035