Value#
- class liesel.model.nodes.Value(value, _name='')[source]#
Bases:
Node
A
Node
subclass 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
Var
to make it appear in the model graph.
- Parameters:
See also
Calc
A node representing a general calculation/operation in JAX or Python.
Dist
A node representing a
tensorflow_probability
Distribution
.Var
A variable in a statistical model, typically with a probability distribution.
param
A helper function to initialize a
Var
as a model parameter.obs
A helper function to initialize a
Var
as 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.GraphBuilder().add(nameless_node).build_model() >>> nameless_node Value(name="n0")
A constant node with a name:
>>> node = lsl.Value(1.0, _name="my_name") >>> node Value(name="my_name")
Methods
add_inputs
(*inputs, **kwinputs)Adds non-keyword and keyword input nodes to the existing ones.
Returns all non-keyword and keyword input nodes as a unique tuple.
Returns all output nodes as a unique tuple.
Clears the state of the node.
Stops the recursion setting outdated flags.
set_inputs
(*inputs, **kwinputs)Sets the non-keyword and keyword input nodes.
update
()Does nothing.
Attributes
The groups that this node is a part of.
The non-keyword input nodes.
The keyword input nodes.
The model the node is part of.
The name of the node.
Whether the node needs a seed / PRNG key.
Whether the node is outdated.
The output nodes.
The state of the node.
The value of the node.
The variable the node is part of.
Whether the node should be monitored by an inference algorithm.