mxfusion.inference.inference_parameters

Members

class mxfusion.inference.inference_parameters.InferenceParameters(constants=None, dtype=None, context=None)

Bases: object

The parameters and outcomes of an inference method.

InferenceParameters is a pool of memory that contains a mapping from uuid to two types of memories (MXNet ParameterDict and Constants).

Parameters:
  • constants ({ModelComponent.uuid : mxnet.ndarray}) – Specify a list of model variables as constants
  • dtype ({numpy.float64, numpy.float32, 'float64', 'float32'}) – data type for internal numberical representation
  • context ({mxnet.cpu or mxnet.gpu}) – The MXNet context
update_constants(constants)
initialize_params(graphs, observed_uuid)
Parameters:
  • graphs (a list of FactorGraph) – a list of graphs in which the parameters will be optimized.
  • observed_uuid (list, set) – Parameter Variables that are passed in directly as data, not to be inferred.
initialize_with_carryover_params(graphs, observed_uuid, var_ties, carryover_params)
Parameters:
  • graphs (a list of FactorGraph) – a list of graphs in which the parameters will be optimized.
  • observed_uuid ({UUID : mx.ndarray}) – Parameter Variables that are passed in directly as data, not to be inferred.
  • var_ties ({ UUID to tie from : UUID to tie to }) – A dictionary of variable maps that are tied together and use the MXNet Parameter of the dict value’s uuid.
  • carryover_params ([InferenceParameters]) – list of InferenceParameters containing the outcomes of previous inference algorithms.
param_dict
constants
var_ties
static load_parameters(uuid_map=None, parameters_file=None, variable_constants_file=None, mxnet_constants_file=None, context=None, dtype=None, current_params=None)

Loads back a sest of InferenceParameters from files. :param parameters_file: These are the parameters of the previous inference algorithm. These are in a {uuid: mx.nd.array} mapping. :type mxnet_constants_file: file saved down with mx.nd.save(), so a {uuid: mx.nd.array} mapping saved in a binary format. :param mxnet_constants_file: These are the constants in mxnet format from the previous inference algorithm. These are in a {uuid: mx.nd.array} mapping. :type mxnet_constants_file: file saved down with mx.nd.save(), so a {uuid: mx.nd.array} mapping saved in a binary format. :param variable_constants_file: These are the constants in primitive format from the previous inference algorithm. :type variable_constants_file: json dict of {uuid: constant_primitive}

save(prefix)

Saves the parameters and constants down to json files as maps from {uuid : value}, where value is an mx.ndarray for parameters and either primitive number types or mx.ndarray for constants. Saves up to 3 files: prefix+[“_params.json”, “_variable_constants.json”, “_mxnet_constants.json”]

Parameters:prefix (str , ex. "../saved_inferences/experiment_1") – The directory and any appending tag for the files to save this Inference as.