Signals¶
-
class
nengo_dl.signals.
TensorSignal
(indices, key, dtype, shape, minibatch_size, label='TensorSignal')[source]¶ Represents a tensor as an indexed view into a base array.
Parameters: - 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)
- minibatch_size : int
If not None then this signal contains a minibatch dimension with the given size
- label : str, optional
Name for this signal, used to make debugging easier
-
__getitem__
(indices)[source]¶ Create a new TensorSignal representing a subset (slice or advanced indexing) of the indices of this TensorSignal.
Parameters: - indices : slice or list of int
The desired subset of the indices in this TensorSignal
Returns: - :class:`.signals.TensorSignal`
A new TensorSignal representing the subset of this TensorSignal
-
reshape
(shape)[source]¶ Create a new TensorSignal representing a reshaped view of the same data in this TensorSignal (size of data must remain unchanged).
Parameters: - shape : tuple of int
New shape for the signal (one dimension can be -1 to indicate an inferred dimension size, as in numpy)
Returns: - :class:`.signals.TensorSignal`
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.Parameters: - 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
Returns: - :class:`.signals.TensorSignal`
TensorSignal with new broadcasted shape
-
load_indices
()[source]¶ 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.
-
full_shape
¶ Shape including the minibatch dimension.
-
minibatched
¶ Whether or not this TensorSignal contains a minibatch dimension.
- indices : tuple or list or
-
class
nengo_dl.signals.
SignalDict
(sig_map, dtype, minibatch_size)[source]¶ Handles the mapping from
Signal
totf.Tensor
.Takes care of gather/scatter logic to read/write signals within the base arrays.
Parameters: - sig_map : dict of {
Signal
:TensorSignal
} Mapping from
nengo
signals tonengo_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
.Parameters: - 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
withval
- dst :
-
gather
(src, force_copy=False)[source]¶ Fetches the data corresponding to
src
from the base array.Parameters: - 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.
Returns: - ``tf.Tensor``
Tensor object corresponding to a dense subset of data from the base array
- src :
-
mark_gather
(src)[source]¶ Marks
src
as being gathered, but doesn’t actually perform a gather. Used to indicate that some computation relies onsrc
.Parameters: - src :
TensorSignal
Signal indicating the data being read
- src :
-
combine
(sigs, load_indices=True, label='Combine')[source]¶ Combines several TensorSignals into one by concatenating along the first axis.
Parameters: - sigs : list of
TensorSignal
orSignal
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)
Returns: - :class:`.TensorSignal`
New TensorSignal representing the concatenation of the data in
sigs
- sigs : list of
- sig_map : dict of {