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, config)[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
totf.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__
)
- ops : tuple of
-
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
totf.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
- ops : tuple of
-
classmethod
-
class
nengo_dl.builder.
OpBuilder
(ops, signals, config)[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
totf.Tensor
(updated by operations)- config :
BuildConfig
General repository for config information builders might want (conglomerated into this object so that we can add/remove config data without having to change the function signature all the time).
-
build_step
(signals)[source]¶ This function builds whatever computations need to be executed in each simulation timestep.
Parameters: - signals :
signals.SignalDict
Mapping from
Signal
totf.Tensor
(updated by operations)
Returns: - 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
- signals :
-
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
totf.Tensor
(updated by operations)- sess :
tf.Session
The initialized simulation session
- rng :
RandomState
Seeded random number generator
- ops : list of
- ops : list of
-
class
nengo_dl.builder.
BuildConfig
[source]¶ Stores configuration parameters that may be relevant to parts of the build process.
Parameters: - inference_only : bool
If True the network should be constructed in “inference only” mode (not including any support for training operations).
- lif_smoothing : float
Smoothing parameter for
LIF
gradient approximation.
Create new instance of BuildConfig(inference_only, lif_smoothing)