Unfortunately I am unable to understand your linked code. However, going with the basics, you can certainly check which spiking neurons in SNNs (in any layer) have activated the most.
In TF-Keras models, there is no temporal dimension while training/inference. Thus, you can simply probe the non-spiking neurons, may be plot the activation maps / heat maps based on their probes output, or do some sort of calculation on their activation values to determine if they are max activated. Since I haven’t done this ever, I am also not sure if there exists a function in TF to help you with it. If at all there exists such a function in TF and you are looking for its equivalent in NengoDL, then I am afraid, it seems there isn’t any.
Although, you can do some basic maths with spiking neurons probed outputs to find which ones are max activated. First, you of course need to probe the spiking neurons of the layers you are interested in, then get their spikes, and then calculate their firing rate which has been done in the tutorial you are referring to. The firing rates of the spiking neurons closely correspond to their activation values in TF environment, i.e. they will be correlated. Thus, you can check which spiking neurons are max activated.
Or, there’s another easy method if you are not interested in explicitly calculating the spikes. You can simply probe the synapse
d output of the spiking neurons (for the last timestep of your simulation), and that will give you it’s “oscillating” activation value (it will be oscillating due to spiking behaviour), and that will generally give you a good approximation of the actual activation value had the model been run in TF environment (you will find the TF activation values and NengoDL activation values to be correlated).
To probe only for the last timestep, you can set the following setting:
with ndl_model.net:
nengo_dl.configure_settings(keep_history=False)
where ndl_model = nengo_dl.Converter(model)
. This will save enormous amount of memory. You can get more info about it here. To probe synapsed values from a layer, you can refer the following example:
with nengo_converter.net:
conv0_probe = nengo.Probe(
nengo_converter.layers[conv0][sample_neurons], synapse=0.005)
Just that it’s going to be a bit of long grunt work, so you have to be careful while coding. For crosschecking if your code is all right, you may plot the correlation plot of non-spiking neurons activation values (obtained in TF environment) and spiking neurons last timestep activation values (obtained in NengoDL environment). The scatter (correlation) plot for randomly chosen neurons (same for both the environments) for Conv/Dense layers would look like the following: