mrftools.PrimalDual module

Primal dual weight learning class

class mrftools.PrimalDual.PrimalDual(inference_type, bp_iter=300, dual_bp_iter=1)[source]

Bases: mrftools.PairedDual.PairedDual

Objects that learn with inner dual optimization interleaved with full inference of latent variables

learn(weights, optimizer=<function ada_grad>, callback=None, opt_args=None)[source]

Fit model parameters my jointly solving the full dual saddle-point objective that includes optimization over estimated expectations of output variables and latent variables as well as weight optimization.

Parameters:
  • weights – Initial weight vector. Can be used to warm start from a previous solution.
  • optimizer – gradient-based optimization function, as defined in opt.py
  • callback – callback function run during each iteration of the optimizer. The function receives the weights as input. Can be useful for diagnostics, live plotting, storing records, etc.
  • opt_args – optimization arguments. Usually a dictionary of parameter values
Returns:

learned weights