spikingjelly icon indicating copy to clipboard operation
spikingjelly copied to clipboard

Bad performance on a convertet ResNet50 on Flower102

Open AndreaDiTrani opened this issue 1 year ago • 4 comments

After fine-tuning a regular RESNET50 on the Flower102 dataset using the following architecture for the classifier:

from torchvision.models import resnet50

resnet = resnet50(weights='ResNet50_Weights.IMAGENET1K_V1')

resnet.fc = nn.Sequential(
    nn.Linear(2048, 512),
    nn.ReLU(inplace=True),
    nn.Dropout(0.5),

    nn.Linear(512, 256),
    nn.ReLU(inplace=True),
    nn.Dropout(0.5),

    nn.Linear(256, 102)
)

this net achieve an accuracy on the test set >90%

after converting using:

model_converter = ann2snn.Converter(mode='max', dataloader = train_dataload_flowers)
converted_model = model_converter(full_resnet)

the performance on the test set drop to an accuracy <10%. I tried to change the conversion mode using: max, 99.99% and 1/3 without obtaining significant improvements.

Issue type

  • [ ] Bug Report
  • [ ] Feature Request
  • [x] Help wanted
  • [x] Other

@DingJianhao @Lyu6PosHao

AndreaDiTrani avatar Apr 03 '23 15:04 AndreaDiTrani

Hi. How many time steps do you use when inferring on test set? Given that resnet50 is a relatively deep network, T (the number of time steps) needs to be large enough, and max mode is not recommended.

Lyu6PosHao avatar Apr 04 '23 06:04 Lyu6PosHao

I tried T = 10, 20, 50 and 100. What kind of mode may improve the performances ?

AndreaDiTrani avatar Apr 04 '23 08:04 AndreaDiTrani

T=100 is not enough, especially for such a deep network. You could try 99.99% (or 1/2, 1/3, etc.) mode and T=512, and check if the accuracy increases. In fact, as for converting of deep networks, it is very difficult to achieve good performance and low latency at the same time unless advanced and complex methods are used, which have not been implemented in SpingJelly currently. And as far as I know, even in the latest research, there are few conversion experiments on resnet50, and most experiments are conducted on resnet18/20/34. So make T larger and give up max mode. If it doesn't help, please refer to the latest relevant papers or wait for the upgrade of ann2snn in SpikingJelly. Good luck.

Lyu6PosHao avatar Apr 04 '23 09:04 Lyu6PosHao

same question to me, the peformance is less than 1% with T=50

201528014227051 avatar Jun 08 '23 02:06 201528014227051