TensorNodes¶
To build TensorNode
objects we need to define a new Nengo operator
(tensor_node.SimTensorNode
), a build function that adds that operator
into a Nengo graph (tensor_node.build_tensor_node()
), and a NengoDL
build class that maps that new Nengo operator to TensorFlow operations
(tensor_node.SimTensorNodeBuilder
).
-
class
nengo_dl.tensor_node.
SimTensorNode
(func, time, input, output, tag=None)[source]¶ Operator for TensorNodes (constructed by
build_tensor_node()
).Parameters: - func : callable
The TensorNode function (
tensor_func
)- time :
Signal
Signal representing the current simulation time
- input :
Signal
or None Input Signal for the TensorNode (or None if size_in==0)
- output :
Signal
Output Signal for the TensorNode
- tag : str, optional
A label associated with the operator, for debugging
Notes
- sets
[output]
- incs
[]
- reads
[time] if input is None else [time, input]
- updates
[]
-
nengo_dl.tensor_node.
build_tensor_node
(model, node)[source]¶ This is the Nengo build function, so that Nengo knows what to do with TensorNodes.
-
class
nengo_dl.tensor_node.
SimTensorNodeBuilder
(ops, signals, config)[source]¶ Builds a
SimTensorNode
operator into a NengoDL model.-
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
-