- class liesel.model.nodes.Node(*inputs, _name='', _needs_seed=False, **kwinputs)[source]#
A node of a computational graph that can cache its value.
Liesel represents statistical models as directed acyclic graphs (DAGs) of random variables (see
Var) and computational nodes. The graph of random variables is built on top of the computational graph. The nodes of the computational graph will typically express computations in JAX returning arrays or pytrees, but in general, they can represent arbitrary operations in Python.
Nodes can cache the result of the operations they represent, improving the efficiency of the graph. The cached values are part of the model state (see
Model.state), and can be stored in a chain by Liesel’s MCMC engine Goose.
This class is an abstract class that cannot be initialized without defining the
update()method. See below for the most important concrete node classes.
Additional meta-information can be added by wrapping a
Calcnode in a
Var, which is particularly useful if the node represents a random variable, but can also be a good idea in a few other situations.
A node representing a general calculation/operation in JAX or Python.
A node representing some static data.
A node representing a TensorFlow Probability distribution, typically for the evaluation of the log-probability.
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.
Flags the node and its recursive outputs as outdated.
Sets the non-keyword and keyword input nodes.
Updates the value of the node.
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.