MAP Optimization

In contrast to parameter optimization, which optimizes parameters of a generative function that are not associated with any prior distribution, maximum a posteriori (MAP) optimization can be used to maximize the posterior probability of a selection of traced random variables:

Gen.map_optimizeFunction
new_trace = map_optimize(trace, selection::Selection,
    max_step_size=0.1, tau=0.5, min_step_size=1e-16, verbose=false)

Perform backtracking gradient ascent to optimize the log probability of the trace over selected continuous choices. Selected random choices must have support on the entire real line.

source

To use map_optimize, a trace of a generative function should be first created using the generate method with the appropriate observations. Users may also implement more complex optimization algorithms beyond backtracking gradient ascent by using the gradients returned by choice_gradients. Note that if the selected random variables have bounded support over the real line, errors may occur during gradient-based optimization.