mxfusion.inference.forward_sampling¶
Members¶
-
class
mxfusion.inference.forward_sampling.
ForwardSamplingAlgorithm
(model, observed, num_samples=1, target_variables=None, extra_graphs=None)¶ Bases:
mxfusion.inference.inference_alg.SamplingAlgorithm
The class of the forward sampling algorithm.
Parameters: - model (Model) – the definition of the probabilistic model
- observed ([Variable]) – A list of observed variables
- num_samples (int) – the number of samples used in estimating the variational lower bound
- target_variables ([UUID]) – (optional) the target variables to sample
- extra_graphs ([FactorGraph]) – a list of extra FactorGraph used in the inference algorithm.
-
compute
(F, variables)¶ Compute the inference algorithm
Parameters: - F (Python module) – the execution context (mxnet.ndarray or mxnet.symbol)
- variables – the set of MXNet arrays that holds the values of
variables at runtime. :type variables: {str(UUID): MXNet NDArray or MXNet Symbol} :returns: the outcome of the inference algorithm :rtype: mxnet.ndarray.ndarray.NDArray or mxnet.symbol.symbol.Symbol
-
class
mxfusion.inference.forward_sampling.
ForwardSampling
(num_samples, model, observed, var_tie, infr_params, target_variables=None, hybridize=False, constants=None, dtype=None, context=None)¶ Bases:
mxfusion.inference.inference.TransferInference
Inference method of forward sampling.
Parameters: - num_samples (int) – the number of samples used in estimating the variational lower bound
- model (Model) – the definition of the probabilistic model
- observed ([Variable]) – A list of observed variables
- var_tie ({ UUID to tie from : UUID to tie to }) – A dictionary of variables that are tied together and use the MXNet Parameter of the dict value’s uuid.
- infr_params (InferenceParameters or [InferenceParameters]) – list or single of InferenceParameters objects from previous Inference runs.
- target_variables ([Variable]) – (optional) the target variables to sample
- hybridize (boolean) – Whether to hybridize the MXNet Gluon block of the inference method.
- constants ({Variable: mxnet.ndarray}) – Specify a list of model variables as constants
- dtype ({numpy.float64, numpy.float32, 'float64', 'float32'}) – data type for internal numerical representation
- context ({mxnet.cpu or mxnet.gpu}) – The MXNet context
-
mxfusion.inference.forward_sampling.
merge_posterior_into_model
(model, posterior, observed)¶ Replace the prior distributions of a model with its variational posterior distributions.
Parameters:
-
class
mxfusion.inference.forward_sampling.
VariationalPosteriorForwardSampling
(num_samples, observed, inherited_inference, target_variables=None, hybridize=False, constants=None, dtype=None, context=None)¶ Bases:
mxfusion.inference.forward_sampling.ForwardSampling
The forward sampling method for variational inference.
Parameters: - num_samples (int) – the number of samples used in estimating the variational lower bound
- observed ([Variable]) – A list of observed variables
- inherited_inference (SVIInference or SVIMiniBatchInference) – the inference method of which the model and inference results are taken
- target_variables ([Variable]) – (optional) the target variables to sample
- 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