mxfusion.inference.grad_based_inference

Members

class mxfusion.inference.grad_based_inference.GradBasedInference(inference_algorithm, grad_loop=None, constants=None, hybridize=False, dtype=None, context=None, logger=None, rv_scaling=None)

Bases: mxfusion.inference.inference.Inference

The abstract class for gradient-based inference methods. An inference method consists of a few components: the applied inference algorithm, the model definition (optionally a definition of posterior approximation), the inference parameters.

Parameters:
  • inference_algorithm (InferenceAlgorithm) – The applied inference algorithm
  • grad_loop (GradLoop) – The reference to the main loop of gradient optimization
  • constants ({Variable: mxnet.ndarray}) – Specify a list of model variables as constants
  • hybridize (boolean) – Whether to hybridize the MXNet Gluon block of the inference method.
  • dtype ({numpy.float64, numpy.float32, 'float64', 'float32'}) – data type for internal numerical representation
  • context ({mxnet.cpu or mxnet.gpu}) – The MXNet context
  • logger (inference.Logger) – The logger to send logs to
  • rv_scaling ({Variable: scaling factor}) – the scaling factor of random variables
create_executor()

Return a MXNet Gluon block responsible for the execution of the inference method.

run(optimizer='adam', learning_rate=0.001, max_iter=2000, verbose=False, **kwargs)

Run the inference method.

Parameters:
  • optimizer (str) – the choice of optimizer (default: ‘adam’)
  • learning_rate (float) – the learning rate of the gradient optimizer (default: 0.001)
  • max_iter (int) – the maximum number of iterations of gradient optimization
  • verbose (boolean) – whether to print per-iteration messages.
  • kwargs – The keyword arguments specify the data for inferences. The key of each argument is the name of

the corresponding variable in model definition and the value of the argument is the data in numpy array format.

class mxfusion.inference.grad_based_inference.GradTransferInference(inference_algorithm, infr_params, train_params, grad_loop=None, var_tie=None, constants=None, hybridize=False, dtype=None, context=None)

Bases: mxfusion.inference.grad_based_inference.GradBasedInference

The abstract Inference method for transferring the outcome of one inference method to another.

Parameters:
  • inference_algorithm (InferenceAlgorithm) – The applied inference algorithm
  • train_params
  • constants ({Variable: mxnet.ndarray}) – Specify a list of model variables as constants
  • hybridize (boolean) – Whether to hybridize the MXNet Gluon block of the inference method.
  • dtype ({numpy.float64, numpy.float32, 'float64', 'float32'}) – data type for internal numerical representation
  • context ({mxnet.cpu or mxnet.gpu}) – The MXNet context