DistRegBuilder.add()

DistRegBuilder.add()#

DistRegBuilder.add(*args, to_float32=True)#

Adds nodes, variables or other graph builders to the graph.

Parameters:
  • *args (Node | Var | GraphBuilder) – The nodes, variables or graph builders to add to the graph. Note that the GraphBuilder will find input nodes recursively for all nodes and variables that are added to it, so you only need to add root nodes.

  • to_float32 (bool) – Whether to convert the dtype of the values of the added nodes from float64 to float32. (default: True)

Return type:

GraphBuilder

See also

GraphBuilder.build_model()

Method for building a model from the GraphBuilder.

GraphBuilder.transform()

Transforms a variable by adding a new transformed variable as an input.

Examples

We start by creating some variables:

>>> a = lsl.Var(1.0, name="a")
>>> b = lsl.Var(2.0, name="b")
>>> c = lsl.Var(lsl.Calc(lambda x, y: x + y, a, b), name="c")

We now initialize a GraphBuilder and add the root node c to it:

>>> gb = lsl.GraphBuilder()
>>> gb.add(c)
GraphBuilder(0 nodes, 1 vars)

We are now ready to build the model:

>>> model = gb.build_model()
>>> model
Model(9 nodes, 3 vars)