# Builder¶

The Builder is in charge of mapping (groups of) Nengo operators to the builder objects that know how to translate those operators into a TensorFlow graph.

class nengo_dl.builder.Builder[source]

Manages the operator build classes known to the nengo_dl build process.

classmethod pre_build(ops, signals, op_builds)[source]

Setup step for build classes, in which they compute any of the values that are constant across simulation timesteps.

Parameters: ops : tuple of Operator The operator group to build into the model signals : signals.SignalDict Mapping from Signal to tf.Tensor (updated by operations) op_builds : dict of {tuple of Operator, :class:~.op_builders.OpBuilder} pre_build will populate this dictionary with the OpBuilder objects (which execute the pre-build step in their __init__)
classmethod build(ops, signals, op_builds)[source]

Build the computations implementing a single simulator timestep.

Parameters: ops : tuple of Operator The operator group to build into the model signals : signals.SignalDict Mapping from Signal to tf.Tensor (updated by operations) op_builds : dict of {tuple of Operator, :class:~.op_builders.OpBuilder} Mapping from operator groups to the pre-built builder objects
classmethod register(nengo_op)[source]

A decorator for adding a class to the build function registry.

Parameters: nengo_op : Operator The operator associated with the build function being decorated.
class nengo_dl.builder.OpBuilder(ops, signals)[source]

The constructor should set up any computations that are fixed for this op (i.e., things that do not need to be recomputed each timestep).

Parameters: ops : list of Operator The operator group to build into the model signals : signals.SignalDict Mapping from Signal to tf.Tensor (updated by operations)
build_step(signals)[source]

This function builds whatever computations need to be executed in each simulation timestep.

Parameters: signals : signals.SignalDict Mapping from Signal to tf.Tensor (updated by operations) list of tf.Tensor, optional If not None, the returned tensors correspond to outputs with possible side-effects, i.e. computations that need to be executed in the TensorFlow graph even if their output doesn’t appear to be used
build_post(ops, signals, sess, rng)[source]

This function will be called after the graph has been built and session/variables initialized.

This should be used to build any random aspects of the operator.

Note that this function may be called multiple times per session, so it should modify the graph in-place.

Parameters: ops : list of Operator The operator group to build into the model signals : signals.SignalDict Mapping from Signal to tf.Tensor (updated by operations) sess : tf.Session The initialized simulation session rng : RandomState Seeded random number generator