putshua / ANN_SNN_QCFS

Code for paper "Optimal ANN-SNN conversion for high-accuracy and ultra-low-latency spiking neural networks"
19 stars 5 forks source link

Convert between new and old versions of state_dict #7

Open USTCYYX opened 6 months ago

USTCYYX commented 6 months ago

In ANN_SNN_QCFS/main_test, I find the code to convert the old version state_dict which train in code SNN_conversion_QCFS, to new version state_dict:

    for k in keys:
        if "relu.up" in k:
            state_dict[k[:-7]+'act.thresh'] = state_dict.pop(k)
        elif "up" in k:
            state_dict[k[:-2]+'thresh'] = state_dict.pop(k)

So if i can use the code

    for k in keys:
        if "relu.thresh" in k:
            state_dict[k[:-11]+'act.up'] = state_dict.pop(k)
        elif "thresh" in k:
            state_dict[k[:-6]+'up'] = state_dict.pop(k)

to convert the new version state_dict to the old version state_dict ? The old version state_dict can be tested in SNN_conversion_QCFS.

putshua commented 6 months ago

I think that works. If you encounter any other problems after doing so, please let me know.