Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording spikes; ids seem to need sorting #45

Open
chanokin opened this issue Feb 12, 2020 · 3 comments
Open

Recording spikes; ids seem to need sorting #45

chanokin opened this issue Feb 12, 2020 · 3 comments

Comments

@chanokin
Copy link
Collaborator

I was getting weird spikes out of simulation, they appeared to be shifted by neuron id. After adding a sort to the new_ids set it looks like this is corrected.

self.id_data_idx_map.update({idd - self.start_id: i + iimap_len
for i, idd in enumerate(new_ids)})

Should become

self.id_data_idx_map.update({idd - self.start_id: i + iimap_len
                                     for i, idd in enumerate(sorted(new_ids))})

I have been unable to generate a small test case, though I've observed this in my big simulations repeatedly. Also, I can only verify this with SpikeSourceArrays as I can compare the input to the output.

@neworderofjamie
Copy link
Contributor

That is interesting! can you try and figure out why sorting might be required? dictionaries in Python are unordered so I'd be a little concerned that this just works around a more fundamental problem with this module...However, I just had a look at the code and I honestly can no longer remember how it worked 😟

@jamesturner246
Copy link
Member

jamesturner246 commented Feb 12, 2020 via email

@chanokin
Copy link
Collaborator Author

From what I can understand, new_ids is a set constructed in PyNN from a Numpy array comming from pynn_genn (which is already sorted! 😠 ). Unfortunately, after the set is created, the ids are scrambled (shifted). The scrambled ids are then used to create a dictionary (id_data_idx_map) which relies on having the correct order (i.e. using enumerate)

It makes sense that, for a set, order does not matter but when mapping neuron-to-data ids, if the neuron ids are not properly sorted the neuron mapping points to the wrong data row. So, it looks like the problem comes from the using set to construct the dictionary, not de dictionary itself.

Annoyingly, I've only seen this in one of the populations in my experiments and, fortunately, it seems to only affect the recording side of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants