# TensorFlow graph construction¶

The TensorGraph class manages all the data and build processes associated with the TensorFlow graph. The TensorFlow graph is the symbolic description of the computations in the network, which will be executed by the simulator.

nengo_dl.tensor_graph.with_self(func)[source]

A decorator that can be used to ensure that any ops created within the wrapped method will be added to the TensorGraph object’s graph.

class nengo_dl.tensor_graph.TensorGraph(model, dt, unroll_simulation, dtype, minibatch_size, device)[source]

Manages the construction of the TensorFlow symbolic computation graph.

Parameters: model : Model Pre-built Nengo model describing the network to be simulated dt : float Length of a simulator timestep, in seconds unroll_simulation : int Unroll simulation loop by explicitly building unroll_simulation iterations into the computation graph dtype : tf.DType Floating point precision to use for simulation minibatch_size : int The number of simultaneous inputs that will be passed through the network device : None or "/cpu:0" or "/gpu:[0-n]" Device on which to execute computations (if None then uses the default device as determined by TensorFlow)
build_step()[source]

Build the operators that execute a single simulation timestep into the graph.

Returns: probe_tensors : list of tf.Tensor The Tensor objects representing the data required for each model Probe side_effects : list of tf.Tensor The output Tensors of computations that may have side-effects (e.g., Node functions), meaning that they must be executed each time step even if their output doesn’t appear to be used in the simulation
build_loop()[source]

Build simulation loop.

Loop can be constructed using the tf.while_loop architecture, or explicitly unrolled. Unrolling increases graph construction time and memory usage, but increases simulation speed.

build_inputs()[source]

Sets up the inputs in the model (which will be computed outside of TensorFlow and fed in each simulation block).

mark_signals()[source]

Mark all the signals in self.model according to whether they represent trainable parameters of the model (parameters that can be optimized by deep learning methods).

Trainable parameters include connection weights, ensemble encoders, and neuron biases. Unless one of those signals is targeted by a Nengo learning rule (otherwise the learning rule update conflicts with the deep learning optimization).

Users can manually specify whether signals are trainable or not using the config system (e.g., net.config[nengo.Ensemble].trainable = False)