class nengo_dl.signals.TensorSignal(indices, key, dtype, shape, minibatched, label='TensorSignal')[source]

Represents a tensor as an indexed view into a base array.

indices : tuple or list or ndarray of int

indices along the first axis of the base array corresponding to the data for this signal

key : object

key mapping to the base array that contains the data for this signal

dtype : dtype

dtype of the values represented by this signal

shape : tuple of int

view shape of this signal (may differ from shape of base array)

minibatched : bool

if True then this signal contains a minibatch dimension

label : str, optional

name for this signal, used to make debugging easier


Create a new TensorSignal representing a subset (slice or advanced indexing) of the indices of this TensorSignal.

indices : slice or list of int

the desired subset of the indices in this TensorSignal


a new TensorSignal representing the subset of this TensorSignal


Create a new TensorSignal representing a reshaped view of the same data in this TensorSignal (size of data must remain unchanged).

shape : tuple of int

new shape for the signal (one dimension can be -1 to indicate an inferred dimension size, as in numpy)


new TensorSignal representing the same data as this signal but with the given shape

broadcast(axis, length)[source]

Add a new dimension by broadcasting this signal along axis for the given length.

axis : 0 or -1

where to insert the new dimension (currently only supports either the beginning or end of the array)

length : int

the number of times to duplicate signal along the broadcast dimension


TensorSignal with new broadcasted shape


Loads the indices for this signal into TensorFlow, and if the indices form a contiguous slice then also loads the start/stop/step of that slice.

class nengo_dl.signals.SignalDict(sig_map, dtype, minibatch_size)[source]

Handles the mapping from Signal to tf.Tensor.

Takes care of gather/scatter logic to read/write signals within the base arrays.

sig_map : dict of {Signal: TensorSignal}

mapping from nengo signals to nengo_dl signals

dtype : tf.DType

floating point precision used in signals

minibatch_size : int

number of items in each minibatch

scatter(dst, val, mode='update')[source]

Updates the base data corresponding to dst.

dst : TensorSignal

signal indicating the data to be modified in base array

val : tf.Tensor

update data (same shape as dst, i.e. a dense array <= the size of the base array)

mode : “update” or “inc”

overwrite/add the data at dst with val

gather(src, force_copy=False)[source]

Fetches the data corresponding to src from the base array.

src : TensorSignal

signal indicating the data to be read from base array

force_copy : bool, optional

if True, always perform a gather, not a slice (this forces a copy). note that setting force_copy=False does not guarantee that a copy won’t be performed.


tensor object corresponding to a dense subset of data from the base array


Marks src as being gathered, but doesn’t actually perform a gather. Used to indicate that some computation relies on src.

src : TensorSignal

signal indicating the data being read

combine(sigs, load_indices=True, label='Combine')[source]

Combines several TensorSignals into one by concatenating along the first axis.

sigs : list of TensorSignal or Signal

signals to be combined

load_indices : bool, optional

if True, load the indices for the new signal into TensorFlow right away (otherwise they will need to be manually loaded later)

label : str, optional

name for combined signal (to help with debugging)


new TensorSignal representing the concatenation of the data in sigs