synsense / sinabs

A deep learning library for spiking neural networks which is based on PyTorch, focuses on fast training and supports inference on neuromorphic hardware.
https://sinabs.readthedocs.io
GNU Affero General Public License v3.0
80 stars 8 forks source link

[Bug] Instance method "find_chip_layer" in todynapcnn.py might need to be re-implemented #126

Closed ssinhaleite closed 11 months ago

ssinhaleite commented 11 months ago

Description

In line #252 in todynapcnn.py, we call "find_chip_layer" to get the chip layer to monitor, however in this expression:

[self.find_chip_layer(lyr) for lyr in monitor_layers]

the variable "monitor_layers" might contains a string "dvs" in it, it will leads to an error, because in line #288 we are using the expression:

return self.chip_layers_ordering[layer_idx]

to obtain the members in a list, however the "layer_idx" might be a string: "dvs".

and the attribute "self.chip_layers_ordering" usually looks like:

print(self.chip_layers_ordering)
>>>
['dvs', 0, 1, 2, 3, 4, 5, 6, 7]

Solution

An easy but inelegant solution is to replace:

monitor_chip_layers = [self.find_chip_layer(lyr) for lyr in monitor_layers]

with

monitor_chip_layers = [self.find_chip_layer(lyr) for lyr in monitor_layers if lyr != "dvs"]

in line #252.

but I think it might be better if we don't contain different types of data members in one list like:

self.chip_layers_ordering
>>>
['dvs', 0, 1, 2, 3, 4, 5, 6, 7]

or the "chip_layers_ordering" and "monitor_layers" variables in the "make_config" method in line #184