Value#
- class liesel.model.Value(value, _name='', convert='default')[source]#
Bases:
NodeA
Nodesubclass that holds constant values.Since the information represented by a value node does not change, it is always up-to-date. A common usecase for value nodes is to cache computed values.
By default, value nodes will appear in the node graph created by
viz.plot_nodes(), but they will not appear in the model graph created byviz.plot_vars().You can wrap a value node in a
Varto make it appear in the model graph.
- Parameters:
value (
Any) – The value of the node._name (
str, default:'') – The name of the node. If you do not specify a name, a unique name will be automatically generated upon initialization of aModel.convert (
Callable[[Any],Any] |Literal['default'], default:'default') – A function used to process the value of this node. The default uses the function stored inconvert_value, which isjax.numpy.asarray.
See also
CalcA node representing a general calculation/operation in JAX or Python.
DistA node representing a
tensorflow_probabilityDistribution.VarA variable in a statistical model, typically with a probability distribution.
paramA helper function to initialize a
Varas a model parameter.obsA helper function to initialize a
Varas an observed variable.
Examples
A simple constant node representing a constant value without a name:
>>> nameless_node = lsl.Value(1.0) >>> nameless_node Value(name="")
Adding this node to a model leads to an automatically generated name:
>>> model = lsl.Model([nameless_node]) >>> nameless_node.name.startswith("_") True
A constant node with a name:
>>> node = lsl.Value(1.0, _name="my_name") >>> node Value(name="my_name")
Methods
Stops the recursion setting outdated flags.
update()Does nothing.
Attributes