DiscreteOptimizer¶
-
class DiscreteOptimizer¶
Refines the categorical probabilities of a DiscreteSampler or DiscreteFlow from accumulated per-category statistics.
The training-time counterpart of DiscreteHistogram — add_data feeds in the per-category weight sums accumulated during a warm-up run, and optimize rewrites every
prob_namesglobal on every context incontextswith the refined distribution.Public Functions
-
inline DiscreteOptimizer(const std::vector<ContextPtr> &contexts, const std::vector<std::string> &prob_names)¶
- Parameters:
contexts – Contexts sharing the probabilities to refine.
prob_names – Global names of the probability tensors, one per discrete dimension.
-
void add_data(const std::vector<Tensor> &values_and_counts)¶
Accumulate one batch of
valuesandcountsfor each dimension ofprob_names, interleaved as[values_0, counts_0, values_1, ...].
-
void optimize()¶
Refine the probabilities from the accumulated data and write them back to every context.
-
inline DiscreteOptimizer(const std::vector<ContextPtr> &contexts, const std::vector<std::string> &prob_names)¶