How to use the nengo.networks function in nengo

To help you get started, we’ve selected a few nengo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hunse / nef-rbm / sigmoid-rbm / run_dbn.py View on Github external
nengo.Connection(bias, layer.input, synapse=0)

        nengo.Connection(output, layer.input, transform=w.T, synapse=pstc)
        output = layer.add_output('sigmoid', function=sigmoid)

        layers.append(layer)

    # --- make code layer
    W, b = weights[-1], biases[-1]
    code_layer = nengo.networks.EnsembleArray(10, b.size, label='code', radius=10)
    code_bias = nengo.Node(output=b)
    nengo.Connection(code_bias, code_layer.input, synapse=0)
    nengo.Connection(output, code_layer.input, transform=W.T, synapse=pstc)

    # --- make classifier layer
    class_layer = nengo.networks.EnsembleArray(10, 10, label='class', radius=20)
    class_bias = nengo.Node(output=bc)
    nengo.Connection(class_bias, class_layer.input, synapse=0)
    nengo.Connection(code_layer.output, class_layer.input,
                     transform=Wc.T, synapse=pstc)

    test = nengo.Node(output=test_dots, size_in=n_labels)
    nengo.Connection(class_layer.output, test)

    probe_code = nengo.Probe(code_layer.output, synapse=0.03)
    probe_class = nengo.Probe(class_layer.output, synapse=0.03)
    probe_test = nengo.Probe(test, synapse=0.01)


# --- simulation
# rundata_file = 'rundata.npz'
# if not os.path.exists(rundata_file):
github hunse / nef-rbm / sigmoid-rbm / run_dbn.py View on Github external
# --- make sigmoidal layers
    layers = []
    output = input_images
    for w, b in zip(weights[:-1], biases[:-1]):
        layer = nengo.networks.EnsembleArray(N, b.size, **neuron_params)
        bias = nengo.Node(output=b)
        nengo.Connection(bias, layer.input, synapse=0)

        nengo.Connection(output, layer.input, transform=w.T, synapse=pstc)
        output = layer.add_output('sigmoid', function=sigmoid)

        layers.append(layer)

    # --- make code layer
    W, b = weights[-1], biases[-1]
    code_layer = nengo.networks.EnsembleArray(10, b.size, label='code', radius=10)
    code_bias = nengo.Node(output=b)
    nengo.Connection(code_bias, code_layer.input, synapse=0)
    nengo.Connection(output, code_layer.input, transform=W.T, synapse=pstc)

    # --- make classifier layer
    class_layer = nengo.networks.EnsembleArray(10, 10, label='class', radius=20)
    class_bias = nengo.Node(output=bc)
    nengo.Connection(class_bias, class_layer.input, synapse=0)
    nengo.Connection(code_layer.output, class_layer.input,
                     transform=Wc.T, synapse=pstc)

    test = nengo.Node(output=test_dots, size_in=n_labels)
    nengo.Connection(class_layer.output, test)

    probe_code = nengo.Probe(code_layer.output, synapse=0.03)
    probe_class = nengo.Probe(class_layer.output, synapse=0.03)
github hunse / nef-rbm / auto / run_lif_nocode.py View on Github external
max_rates=max_rate*np.ones(n),
                               intercepts=intercept*np.ones(n))
        bias = nengo.Node(output=b)
        nengo.Connection(bias, layer.neurons, transform=np.eye(n), synapse=0)

        if i == 0:
            nengo.Connection(input_images, layer.neurons,
                             transform=W.T, synapse=pstc)
        else:
            nengo.Connection(layers[-1].neurons, layer.neurons,
                             transform=W.T * amp / dt, synapse=pstc)

        layers.append(layer)

    # --- make cleanup
    class_layer = nengo.networks.EnsembleArray(Nclass, 10, label='class', radius=5)
    class_bias = nengo.Node(output=bc)
    nengo.Connection(class_bias, class_layer.input, synapse=0)
    nengo.Connection(layers[-1].neurons, class_layer.input,
                     transform=Wc.T * amp / dt, synapse=pstc)

    test = nengo.Node(output=test_dots, size_in=n_labels)
    nengo.Connection(class_layer.output, test)

    # --- make centroid classifier node
    def centroid_test_fn(t, x):
        i = int(t / presentation_time)
        d = ((x - code_means)**2).sum(1)
        return test_labels[i] == labels[np.argmin(d)]

    centroid_test = nengo.Node(centroid_test_fn, size_in=layers[-1].n_neurons)
    nengo.Connection(layers[-1].neurons, centroid_test,
github hunse / nef-rbm / nlif-deep-nengo.py View on Github external
else:
            nengo.Connection(layers[-1].neurons, layer.neurons,
                             transform=W.T * amp, synapse=pstc)

        layers.append(layer)

    # --- make code layer
    W, b = weights[-1], biases[-1]
    code_layer = nengo.networks.EnsembleArray(50, b.size, label='code', radius=15)
    code_bias = nengo.Node(output=b)
    nengo.Connection(code_bias, code_layer.input, synapse=0)
    nengo.Connection(layers[-1].neurons, code_layer.input,
                     transform=W.T * amp * 1000, synapse=pstc)

    # --- make cleanup
    class_layer = nengo.networks.EnsembleArray(100, 10, label='class', radius=15)
    class_bias = nengo.Node(output=bc)
    nengo.Connection(class_bias, class_layer.input, synapse=0)
    nengo.Connection(code_layer.output, class_layer.input,
                     transform=Wc.T, synapse=pstc)

    test = nengo.Node(output=test_dots, size_in=n_labels)
    nengo.Connection(class_layer.output, test)

    probe_code = nengo.Probe(code_layer.output, synapse=0.03)
    probe_class = nengo.Probe(class_layer.output, synapse=0.03)
    probe_test = nengo.Probe(test, synapse=0.01)


# --- simulation
# rundata_file = 'rundata.npz'
# if not os.path.exists(rundata_file):
github hunse / nef-rbm / nlif-deep-nengo.py View on Github external
intercepts=intercept*np.ones(n))
        bias = nengo.Node(output=b)
        nengo.Connection(bias, layer.neurons, transform=np.eye(n), synapse=0)

        if i == 0:
            nengo.Connection(input_images, layer.neurons,
                             transform=W.T, synapse=pstc)
        else:
            nengo.Connection(layers[-1].neurons, layer.neurons,
                             transform=W.T * amp, synapse=pstc)

        layers.append(layer)

    # --- make code layer
    W, b = weights[-1], biases[-1]
    code_layer = nengo.networks.EnsembleArray(50, b.size, label='code', radius=15)
    code_bias = nengo.Node(output=b)
    nengo.Connection(code_bias, code_layer.input, synapse=0)
    nengo.Connection(layers[-1].neurons, code_layer.input,
                     transform=W.T * amp * 1000, synapse=pstc)

    # --- make cleanup
    class_layer = nengo.networks.EnsembleArray(100, 10, label='class', radius=15)
    class_bias = nengo.Node(output=bc)
    nengo.Connection(class_bias, class_layer.input, synapse=0)
    nengo.Connection(code_layer.output, class_layer.input,
                     transform=Wc.T, synapse=pstc)

    test = nengo.Node(output=test_dots, size_in=n_labels)
    nengo.Connection(class_layer.output, test)

    probe_code = nengo.Probe(code_layer.output, synapse=0.03)