mxfusion.components.functions.function_evaluation

Members

class mxfusion.components.functions.function_evaluation.FunctionEvaluation(inputs, outputs, input_names, output_names, broadcastable=False)

Bases: mxfusion.components.factor.Factor

The evaluation of a function with specified input variables.

Parameters:
  • inputs ({variable name : Variable}) – the input variables to the function.
  • outputs ({variable name : Variable}) – the output variables to the function.
  • broadcastable – Whether the function supports broadcasting with the additional dimension for samples.
Type:

boolean

replicate_self(attribute_map=None)

This functions is a copy constructor for the object. In order to perform copy construction we first call __new__() on the class which creates a blank object. We then initialize that object using the method’s standard init procedures, and do any extra copying of attributes.

Replicates this Factor, using new inputs, outputs, and a new uuid. Used during model replication to functionally replicate a factor into a new graph.

Parameters:
  • inputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new input variables of the factor.
  • outputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new output variables of the factor.
eval(F, variables, always_return_tuple=False)

Evaluate the function with the pre-specified input arguments in the model defintion. All the input arguments are automatically collected from a dictionary of variables according to the UUIDs of the input arguments.

Parameters:
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
  • variables ({str(UUID): MXNet NDArray or Symbol}) – the set of variables where the dependent variables are collected from.
  • always_return_tuple – whether to always return the function outcome in a tuple, even if there is only

one output variable. This makes programming easy, as the downstream code can consistently expect a tuple. :type always_return_tuple: boolean :returns: the outcome of the function evaluation :rtypes: MXNet NDArray or MXNet Symbol or [MXNet NDArray or MXNet Symbol]

eval_impl(F, **input_kws)

The method handling the execution of the function.

Parameters:
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray)
  • **input_kws

    the dict of inputs to the functions. The key in the

dict should match with the name of inputs specified in the inputs of FunctionEvaluation. :type **input_kws: {variable name: MXNet NDArray or MXNet Symbol} :returns: the return value of the function :rtypes: MXNet NDArray or MXNet Symbol

class mxfusion.components.functions.function_evaluation.FunctionEvaluationWithParameters(func, input_variables, output_variables, broadcastable=False)

Bases: mxfusion.components.functions.function_evaluation.FunctionEvaluation

The evaluation of a function with internal function parameters.

Parameters:
  • func – the function that this evaluation is generated from
  • input_variables ({str : Variable}) – MXFusion.components.functions.MXFusionFunction
  • output_variables ({str : Variable}) – the output variables of the function.
  • broadcastable – Whether the function supports broadcasting with the additional dimension for samples.
Type:

boolean

replicate_self(attribute_map=None)

This functions is a copy constructor for the object. In order to perform copy construction we first call __new__() on the class which creates a blank object. We then initialize that object using the method’s standard init procedures, and do any extra copying of attributes.

Replicates this Factor, using new inputs, outputs, and a new uuid. Used during model replication to functionally replicate a factor into a new graph.

Parameters:
  • inputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new input variables of the factor.
  • outputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new output variables of the factor.
parameters
function
eval_impl(F, **input_kws)

Invokes the MXNet Gluon block with the arguments passed in.

Parameters:
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray)
  • input_kws – the dict of inputs to the functions. The key in the dict should match with the name of

inputs specified in the inputs of FunctionEvaluation. :type input_kws: {variable name: MXNet NDArray or MXNet Symbol} :returns: the return value of the function :rtypes: MXNet NDArray or MXNet Symbol