project-rig / nengo_spinnaker

SpiNNaker based Nengo simulator.
MIT License
13 stars 7 forks source link

Adding neuron input to EnsembleArray raises error #89

Open pabogdan opened 8 years ago

pabogdan commented 8 years ago

Minimal example:

import nengo
import numpy as np

model = nengo.Network("Broken!")

with model:
    some_input = nengo.Node(np.sin)
    some_inhibition = nengo.Node(np.cos)

    A = nengo.networks.EnsembleArray(n_neurons=100, n_ensembles=1, ens_dimensions=1)
    inhibiting_input = A.add_neuron_input()

    nengo.Connection(some_input, A.input)
    nengo.Connection(some_inhibition, inhibiting_input, transform=[[-2.5]]*100)

This works with nengo, fails with nengo_spinnaker.

Traceback (most recent call last):
  File "/home/bogdanp/nengo_gui/nengo_gui/page.py", line 435, in build
    self.sim = backend.Simulator(self.model)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/simulator.py", line 103, in __init__
    self.model.build(network, **builder_kwargs)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/builder.py", line 204, in build
    self._build_network(network)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/builder.py", line 212, in _build_network
    self._build_network(subnet)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/builder.py", line 224, in _build_network
    self.make_connection(connection)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/builder.py", line 257, in make_connection
    sink = self._sink_getters[post_type](self, conn)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/ensemble.py", line 64, in get_neurons_sink
    elif np.all(connection.transform[1:] == connection.transform[0]):
ValueError: cannot slice a 0-d array
mundya commented 8 years ago

(Just a note, this is kind of an instance of #30)

mundya commented 8 years ago

Fixing this is on the todo list for Spaun, a quick work around whenever you want to do this kind of thing is:

for ens in A.ea_ensembles:
    nengo.Connection(x, ens.neurons, transform=[[-2.5]] * ens.n_neurons)
pabogdan commented 8 years ago

This is the effect of the suggested hack. Should I revert back to multiple Ensembles instead of using EnsembleArrays?

Traceback (most recent call last):
  File "/home/bogdanp/nengo_gui/nengo_gui/page.py", line 464, in runner
    self.sim.run_steps(self.sim.max_steps)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/simulator.py", line 195, in run_steps
    self._run_steps(n_steps)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/simulator.py", line 246, in _run_steps
    self.host_sim.step()
  File "/usr/local/lib/python2.7/dist-packages/nengo-2.1.0_dev-py2.7.egg/nengo/simulator.py", line 181, in step
    step_fn()
  File "/usr/local/lib/python2.7/dist-packages/nengo-2.1.0_dev-py2.7.egg/nengo/builder/operator.py", line 384, in step_simpyfunc
    y = fn(t_sig.item(), *args) if t_in else fn(*args)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/simulator.py", line 305, in func
    return f(t, x)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/builder/node.py", line 380, in output
    self.controller.set_node_output(self.target, value)
  File "/home/bogdanp/nengo_spinnaker/nengo_spinnaker/node_io/ethernet.py", line 128, in set_node_output
    self.out_socket.sendto(packet.bytestring,
  File "/usr/local/lib/python2.7/dist-packages/rig-0.8.0-py2.7.egg/rig/machine_control/packets.py", line 65, in bytestring
    (self.src_port & 0x7) << 5 | (self.src_cpu & 0x1f),
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
mundya commented 8 years ago

Sorry, can you update your copy of Rig?

pabogdan commented 8 years ago

I don't know what x is, but I can running the debugger and check. Will also update rig and see how it goes.

Update 1: pip causing issues and trying to install numpy. Will try and install rig manually, from git

mundya commented 8 years ago

(Re x, I meant the object you were connecting to the neurons from [in the example from 3 days ago])

pabogdan commented 8 years ago

Manually installing rig from git seems to work (could you please update the pip packages so that everything works with python setup.py by default?).

I am connecting the output of a Basal Ganglia directly to the neurons, so the transform is [[1]] * n_neurons

@mundya thank you!

mundya commented 8 years ago

could you please update the pip packages so that everything works with python setup.py by default?

As far as I can tell the version of Rig on PIP is correct (0.10.0), did pip install -U rig not work for you?

mossblaser commented 8 years ago

Manually installing rig from git seems to work (could you please update the pip packages so that everything works withpython setup.py by default?).

The offending change is already released, I believe. Try

pip install "rig>=0.10.0"

On 30 November 2015 at 09:56, Petrut Antoniu Bogdan < notifications@github.com> wrote:

Manually installing rig from git seems to work (could you please update the pip packages so that everything works with python setup.py by default?).

I am connecting the output of a Basal Ganglia directly to the neurons, so the transform is [[1]] * n_neurons

— Reply to this email directly or view it on GitHub https://github.com/project-rig/nengo_spinnaker/issues/89#issuecomment-160581057 .

mundya commented 8 years ago

@pabogdan - when you're back from your well-earned break would you mind seeing if this is still a problem for you? Thanks :)

pabogdan commented 8 years ago

@mundya I will definitely :) This will be around the 5th of July.

mundya commented 8 years ago

Thanks, 'fraid I won't be around until 19th.