mxfusion.components.variables.variable

Members

class mxfusion.components.variables.variable.VariableType

Bases: enum.Enum

Variables types:

  • CONSTANT: a variable with a constant value
  • PARAMETER: a variable with no prior distribution
  • RANDVAR: a variable that follows a distribution or module
  • FUNCVAR: a variable that is an output of a function
CONSTANT = 0
PARAMETER = 1
RANDVAR = 2
FUNCVAR = 3
class mxfusion.components.variables.variable.Variable(value=None, shape=None, transformation=None, isInherited=False, initial_value=None)

Bases: mxfusion.components.model_component.ModelComponent

Define a variable in MXFusion. The variable can be either a constant, a parameter, an outcome of a function evaluation or a random variable following a probabilistic distribution.

Parameters:
  • value ((optional) None or numpy array or MXNet array or float or int or FunctionEvaluation or Distribution.) – The value of variable. If it is a numpy or MXNet array, the variable is considered as a constant. If it is a function evaluation, the variable is considered as the outcome of a function evaluation. If it is a probabilistic distribution, the variable is considered as a random variable. If it is None, the variable is considered as a parameter.
  • shape ((optional) tuple or None) – The expected shape of the Variable.
  • transformation ((optional) transformation or None) – The constraint on the domain of the variable, e.g., a positive value.
  • isInherited (bool) – True if the Variable is constructed from a GluonBlock parameter.
type
as_json()
replicate_self(attribute_map=None)

This functions as a copy constructor for the object. In order to do a copy constructor we first call __new__ on the class which creates a blank object. We then initialize that object using the methods 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:attribute_map ({Variable: replicated Variable}) – A mapping from attributes of this object that were Variables to their replicants.
shape_str
display_str(temp_name=None)
set_prior(distribution)

Set the prior over this variable.

Param:distribution The distribution the variable is drawn from.
assign_factor(factor)

Assign (or reassign) the distribution this variable is drawn from.

Param:distribution The distribution this variable is drawn from.
factor
constant

Return the stored constant.

Returns:the constant value
transformation
initial_value
initial_value_before_transformation

The initial value of a variable before applying the chosen transformation (if exists)