fabrizio-ottati / icons23-tutorial

GNU General Public License v2.0
3 stars 1 forks source link

Weights #1

Open Maya7991 opened 2 months ago

Maya7991 commented 2 months ago

Hello,

Can you provide an example for the weights used? It will help me understand the format in which they must be provided

#include "weights.h"
#include "weights_layer0.h"
#include "weights_layer1.h"

Thanks, Maya

fabrizio-ottati commented 2 months ago

Hi Maya, the weights are provided in HWC format. It means that the shape tuple is (outputChannels, height, width, inputChannels).

Maya7991 commented 2 months ago

Thank you @fabrizio-ottati for the answer. I have done QAT of weights of my SnnTorch model using the Brevitas library as suggested in the Python script. Then I have extracted and stored the INT8 weights using the following snippet as Brevitas does only fake quantization.

for name, module in model.named_modules():
        if isinstance(module, qnn.QuantLinear):
            quantized_weights[f'{name}.weight'] = module.quant_weight().int().detach().cpu().numpy()

Now, I have stored the weights. The Threshold of Leaky neuron is the default Threshold of 1V in my model. But how can I get the new Threshold value of the LIF neuron corresponding to the INT weights. Can I get this from the SnnTorch model? I am confused on how to determine this value and have been struggling with this for a long time. It will be of great help if you can answer this question. Given below are my neuron parameters:

beta = 1
spike_grad = surrogate.fast_sigmoid(slope=25)
self.lif= snn.Leaky(beta=beta, spike_grad=spike_grad, init_hidden=True) 

Thank you for your time.