Expand description
Pure-Rust distribution utilities for CPU-based sampling and log-prob. These are backend-independent helpers that can be used by any backend or for testing without a NN framework.
Functionsยง
- categorical_
entropy - Compute entropy of a categorical distribution from logits.
- categorical_
log_ prob - Compute log_prob for a categorical distribution.
- categorical_
sample - Sample from a categorical distribution given logits. Uses the Gumbel-max trick for differentiable-friendly sampling.
- log_
softmax - Compute log(softmax(logits)) in a numerically stable way. Returns a vector of the same length as logits.
- normal_
entropy - Compute entropy of a normal distribution.
- normal_
log_ prob - Compute log_prob for a normal distribution.
- tanh_
log_ prob_ correction - Tanh squashing log-prob correction: log_prob -= log(1 - tanh(x)^2 + eps)