BICLab / EMS-YOLO

Offical implementation of "Deep Directly-Trained Spiking Neural Networks for Object Detection" (ICCV2023)
https://arxiv.org/abs/2307.11411
GNU General Public License v3.0
139 stars 12 forks source link

The Problem of Computing SyOPs in SNN Model #12

Open ZHENG2049 opened 5 months ago

ZHENG2049 commented 5 months ago

In your paper, I saw that you compared the Energy Efficiency of EMS-ResNet with ANN-Res, MS-Res, and Sew-Res. You provided the firing rate in the paper, but I could not find information on SyOPs, which, according to the formula you provided, $Eb=T\times(fr\times E{AC}\times OP{AC}+E{MAC}\times OP_{MAC}) (6)$ , should be an important indicator of the model's Energy Consumption. I saw potentially related code in your calculate_fr.py:

attention_name = "mem_update.forward"
fr=np.zeros(len(cache[attention_name]))
at_size=np.zeros(len(cache[attention_name]))
for att_index in range(len(cache[attention_name])):
    # visualize_grid_to_grid(save_dir,att_index,attention_name,att_map,image)
    fr[att_index]=cache[attention_name][att_index].sum()/cache[attention_name][att_index].size
for att_index in range(len(cache[attention_name])):
    at_size[att_index]=cache[attention_name][att_index].size
# calculate firing rate
FR.append(fr)
SZ.append(at_size)

SZ seem to be attempting to calculate the number of operations in mem_update, but I encountered some issues when running the code:

Traceback (most recent call last):
File "/home/ps/EMS-YOLO/calculate_fr.py", line 355, in <module>
  main(opt)
File "/home/ps/EMS-YOLO/calculate_fr.py", line 361, in main
  run(**vars(opt))
File "/home/ps/miniconda3/envs/emsyolo/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
  return func(*args, **kwargs)
File "/home/ps/EMS-YOLO/calculate_fr.py", line 235, in run
  fr=np.zeros(len(cache[attention_name]))
KeyError: 'mem_update.forward'

How can I solve this problem?