Networks

nengo_extras.networks.MatrixMult(n_neurons, shape_left, shape_right, net=None)[source]

Computes the matrix product A*B.

Both matrices need to be two dimensional.

See the Matrix Multiplication example for a description of the network internals.

Parameters
n_neuronsint

Number of neurons used per product of two scalars.

Note

If an odd number of neurons is given, one less neuron will be used per product to obtain an even number. This is due to the implementation the Product network.

shape_lefttuple

Shape of the A input matrix.

shape_righttuple

Shape of the B input matrix.

netNetwork, optional (Default: None)

A network in which the network components will be built. This is typically used to provide a custom set of Nengo object defaults through modifying net.config.

Returns
netNetwork

The newly built matrix multiplication network, or the provided net.

nengo_extras.networks.Product(n_neurons, dimensions, input_magnitude=1, net=None)[source]

Computes the element-wise product of two equally sized vectors.

Utilities

nengo_extras.probe.probe_all(net, recursive=False, probe_options=None, **probe_args)[source]

Probes all objects in a network.

Parameters
netnengo.Network
recursivebool, optional (Default: False)

Probe subnetworks recursively.

probe_options: dict, optional (Default: None)

A dict of the form {nengo_object_class: [attributes_to_probe]}. If None, every probeable attribute of every object will be probed.

Returns
A dictionary that maps objects and their attributes to their probes.

Examples

Probe the decoded output and spikes in all ensembles in a network and its subnetworks:

with nengo.Network() as model:
    ens1 = nengo.Ensemble(n_neurons=1, dimensions=1)
    node1 = nengo.Node(output=[0])
    conn = nengo.Connection(node1, ens1)
    subnet = nengo.Network(label='subnet')
    with subnet:
        ens2 = nengo.Ensemble(n_neurons=1, dimensions=1)
        node2 = nengo.Node(output=[0])
probe_options = {nengo.Ensemble: ['decoded_output', 'spikes']}
probes = probe_all(model, recursive=True, probe_options=probe_options)