# Experiment 

⚠️Please notice the number of batch size（2048 in total for ImageNet as same as in Barlow Twins paper, 256 for CIFAR10) assigned to each GPU, if GPU number changes.

## ImageNet
To implement Vit-8-512 based Barlow twins on ImageNet, please conduct
```
cd ImageNet
``` 

⚠️Note:

General setting for all experiment groups: epoch=1000, time-step=4 if use LIF.
If want modify ```batch_size``` value, please modify it in ```imagenet/imagenet.yml```.

For linear-evaluation, fine tuning on 1%/10% labels, as well as transfer learning steps, please fill up the resume model file path by hand, which is a model status dict path saved during SSL training. Normally, it's saved under ```output/train```. 

|||Settings in Command Line|
|:-------:|:-------:|:-------:|
|Method|Step| Vit-8-512-ImageNet|
|firstlast-timestep loss, MixedLIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 train.py --cross-temporal=True --simplified-loss=True --act-func=MixedLIF --log-interval=200 --clip-grad=50000 --batch-size 20 --dataset /mnt/vstor/CSE_ECSE_GXD234/data/imagenet --workers 2```|
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
||fine tune on 1% labels|``` python finetune_semisupervised_learning.py --eval_proportion=0.01 --val_epochs=60 --resume="" ```|
||fine tune on 10% labels|``` python finetune_semisupervised_learning.py --eval_proportion=0.1 --val_epochs=30 --resume="" ```|
||transfer learning|```python transfer_learning.py --eval_proportion=1 --dataset="torch/cifar10" --resume=""```, ```python transfer_learning.py --eval_proportion=1 --dataset="torch/Oxford flowers" --resume="" ```|


## Cifar10
To implement Vit-4-38 based Barlow twins on cifar10, please conduct
```
cd cifar10
``` 

⚠️Note: basic settings and needed modifications are same as ImageNet, which is mentioned above.

|||Settings in Command Line|
|:-------:|:-------:|:-------:|
|Method|Step| Vit-4-384-Cifar10|
|firstlast-timestep loss, MixedLIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --cross-temporal=True --simplified-loss=True --act_func=MixedLIF --log-interval=200 --clip-grad=50000 ```|
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
||fine tune on 1% labels|``` python finetune_semisupervised_learning.py --eval_proportion=0.01 --val_epochs=60 --resume="" ```|
||fine tune on 10% labels|``` python finetune_semisupervised_learning.py --eval_proportion=0.1 --val_epochs=30 --resume="" ```|

### Ablation study:

|||Settings in Command Line|
|:-------:|:-------:|:-------:|
|Method|Step| Vit-4-384-Cifar10|
|firstlast-timestep loss, LIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --cross-temporal=True --simplified-loss=True --act_func=LIFt --log-interval=200 --clip-grad=50000 ```|
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
|cross temporal loss, MixedLIF|ssl training|  ```CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --cross-temporal=True --simplified-loss=False --act_func=MixedLIF --log-interval=200 --clip-grad=50000 ``` |
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
|non-temporal loss, MixedLIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --temporal-loss=False --act_func=MixedLIF --log-interval=200 --clip-grad=50000 ```|
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
|cross temporal loss, LIF|ssl training|  ```CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --cross-temporal=True --simplified-loss=False --act_func=LIFt --log-interval=200 --clip-grad=50000 ``` |
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|
|non-temporal loss, LIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.py --temporal-loss=False --act_func=LIFt --log-interval=200 --clip-grad=50000 ```|
||linear evaluation|```python evaluation.py --eval_proportion=1 --resume=""```|

## dvs-Cifar10
To implement Vit-4-38 based Barlow twins on cifar10, please conduct
```
cd cifar10dvs
``` 

⚠️Note: basic settings and needed modifications are same as ImageNet, which is mentioned above. Exception, please modify ```batch_size``` value  and  ```resume``` in ```train.py```. And please put dvs dataset ```dvs-cifar10``` under this root.

|||Settings in Command Line|
|:-------:|:-------:|:-------:|
|Method|Step| Vit-4-384-Cifar10dvs|
|firstlast-timestep loss, MixedLIF|ssl training|   ``` CUDA_VISIBLE_DEVICES=0,1 torchrun train.py ```|
||linear evaluation|```python evaluation.py```|



## Reqirements

cupy

pyyaml

timm==0.5.4

spikingjelly==0.0.0.0.12


