nengo / nengo-dl

Deep learning integration for Nengo
https://www.nengo.ai/nengo-dl
Other
88 stars 22 forks source link

Trainable parameters in Nengo LIF neurons #225

Closed Anchick closed 2 years ago

Anchick commented 2 years ago

I wanted to extract weights and biases from a network trained in NengoDL and import them to PyTorch based SNN.

I have followed https://www.nengo.ai/nengo-dl/v3.4.4/examples/spiking-mnist.html example and wanted to extract weights from this trained network. I have managed to find them inside sim.data.sim.keras_model.weights . However, there was 'base_params/trainable_float32_NNN:0' key inside this dictionary, besides weights and biases. 'NNN' inside a key name corresponds to a total number of LIF neurons in my network. And this key refers to a ndarray with a shape of (NNN,).

I have looked through the source code for nengo.neurons, but I didn't notice any mention of trainable parameters for LIF neurons.

What is this trainable parameter? Is it a threshold value for each LIF neuron?

drasmuss commented 2 years ago

Those are probably the encoders you're looking at. They aren't actually used in the spiking MNIST example, they're only used if you're doing NEF-style representation (you can see an example with more information about that here). You could mark them explicitly non-trainable using the trainable config option (see https://www.nengo.ai/nengo-dl/config.html#trainable), by setting net.config[nengo.Ensemble].trainable = False and net.config[nengo.ensemble.Neurons] = True, in which case they'd probably be optimized out of the network entirely.

If you have any more questions, the forum is probably your best bet for getting information about the theory underlying Nengo/NengoDL!

Anchick commented 2 years ago

Thank you for a reply.

I have disabled Ensemble training and it is no longer appears in a dictionary.