Commit 3f38e094 authored by dangtrunganh's avatar dangtrunganh

initial commit

parent eaea3ef3
# SAMix # FC-NCCL
Official code for: Official code for:
**"SAMix: Calibrated and Accurate Continual Learning via Sphere-Adaptive Mixup and Neural Collapse"** **"Memory-efficient Continual Learning with Neural Collapse Contrastive"** (WACV2025)
--- ---
...@@ -82,59 +82,27 @@ Official code for: ...@@ -82,59 +82,27 @@ Official code for:
### 4.1. CIFAR-10 ### 4.1. CIFAR-10
- **FC-NCCL with SAMix**
```bash ```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_samix_cf10.sh MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_cf10.sh
```
- **TA-NCCL with SAMix**
```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/ta_nccl/ta_nccl_samix_cf10.sh
``` ```
### 4.2. CIFAR-100 ### 4.2. CIFAR-100
- **FC-NCCL with SAMix**
```bash ```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_samix_cf100.sh MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_cf100.sh
```
- **TA-NCCL with SAMix**
```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/ta_nccl/ta_nccl_samix_cf100.sh
``` ```
### 4.3. Tiny-ImageNet ### 4.3. Tiny-ImageNet
- **FC-NCCL with SAMix**
```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_samix_tiny_imagenet.sh
```
- **TA-NCCL with SAMix**
```bash ```bash
MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/ta_nccl/ta_nccl_samix_tiny_imagenet.sh MEM_SIZE=200 LOG_FOLDER_ZERO_MEM=not-use bash scripts/train/fc_nccl/fc_nccl_tiny_imagenet.sh
``` ```
> **Note 1:**
> Set `LOG_FOLDER_ZERO_MEM` to the log folder containing 200 auxiliary samples if `MEM_SIZE=0` (memory-free setting).
> **Note 2:** > **Note:**
> **To run without SAMix:** > Set `LOG_FOLDER_ZERO_MEM` to the log folder containing 200 auxiliary samples if `MEM_SIZE=0` (memory-free setting).
> 1. Remove these arguments:
> ```bash
> --samix \
> --loss_normal_samples fnc2 \
> --weight_samix_loss 5.0 \
> ```
> 2. Change `--loss nc_samix` to:
> ```bash
> --loss fnc2
> ```
> or
> ```bash
> --loss dr
> ```
> 3. If using `--loss fnc2`, add `--focal_gamma` and `--main_mark`
---
## 🧪 Evaluation ## 🧪 Evaluation
...@@ -157,22 +125,6 @@ CHECKPOINT_FOLDER=/path/check/point/folder LOG_FOLDER=/path/log/folder/ bash scr ...@@ -157,22 +125,6 @@ CHECKPOINT_FOLDER=/path/check/point/folder LOG_FOLDER=/path/log/folder/ bash scr
--- ---
## 📊 Network Calibration
**Modify bash file:** "scripts/calibration/run_calibration.sh", and then run:
```bash
bash scripts/calibration/run_calibration.sh
```
This will compute and display:
- Expected Calibration Error (ECE) each task
- Overconfidence Error (OE) each task
- Average Expected Calibration Error (AECE)
- Average Overconfidence Error (AOE)
---
## 📂 Project Structure ## 📂 Project Structure
``` ```
...@@ -216,4 +168,3 @@ root_path: in 'root_save_folder' in config/base.yaml ...@@ -216,4 +168,3 @@ root_path: in 'root_save_folder' in config/base.yaml
│ │ │ │── prototypes_dim={d}_k={n_cls}_seed={seed}.npy │ │ │ │── prototypes_dim={d}_k={n_cls}_seed={seed}.npy
│ │ │ │── subset_indices_random_{i}.npy │ │ │ │── subset_indices_random_{i}.npy
│ │ │ │── replay_indices_random_{i}.npy │ │ │ │── replay_indices_random_{i}.npy
#!/bin/bash
# Run calibration computation
python main_compute_calibration.py \
--dataset cifar10 \
--target_task 4 \
--n_bins 10 \
--checkpoint_path \path\checkpoint_name.pth \
--classifier_path \path\classifier.pth
\ No newline at end of file
...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \ ...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \
--wandb \ --wandb \
--wandb_project_name your_project_name \ --wandb_project_name your_project_name \
--wandb_entity your_entity \ --wandb_entity your_entity \
--job_run_name fcnccl-samix-cf10-m-${MEM_SIZE} \ --job_run_name fcnccl-cf10-m-${MEM_SIZE} \
--distillation hsd \ --distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \ --log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \ --loss fnc2 \
--loss_normal_samples fnc2 \
--weight_samix_loss 5.0 \
--filter_distillation_point \ --filter_distillation_point \
--samix \
--predictor_hidden_dim 128 \ --predictor_hidden_dim 128 \
--main_mark 30 \ --main_mark 30 \
--focal_gamma 1 --focal_gamma 1
\ No newline at end of file
...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \ ...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \
--wandb \ --wandb \
--wandb_project_name your_project_name \ --wandb_project_name your_project_name \
--wandb_entity your_entity \ --wandb_entity your_entity \
--job_run_name fcnccl-samix-cf100-m-${MEM_SIZE} \ --job_run_name fcnccl-cf100-m-${MEM_SIZE} \
--distillation hsd \ --distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \ --log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \ --loss fnc2 \
--loss_normal_samples fnc2 \
--weight_samix_loss 5.0 \
--filter_distillation_point \ --filter_distillation_point \
--samix \
--predictor_hidden_dim 128 \ --predictor_hidden_dim 128 \
--main_mark 30 \ --main_mark 30 \
--focal_gamma 4 --focal_gamma 4
\ No newline at end of file
...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \ ...@@ -17,14 +17,11 @@ python3 -W ignore main_train.py \
--wandb \ --wandb \
--wandb_project_name your_project_name \ --wandb_project_name your_project_name \
--wandb_entity your_entity \ --wandb_entity your_entity \
--job_run_name fcnccl-samix-tiny-imagenet-m-${MEM_SIZE} \ --job_run_name fcnccl-tiny-imagenet-m-${MEM_SIZE} \
--distillation hsd \ --distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \ --log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \ --loss fnc2 \
--loss_normal_samples fnc2 \
--weight_samix_loss 5.0 \
--filter_distillation_point \ --filter_distillation_point \
--samix \
--predictor_hidden_dim 256 \ --predictor_hidden_dim 256 \
--main_mark 20 \ --main_mark 20 \
--focal_gamma 4 --focal_gamma 4
\ No newline at end of file
python3 -W ignore main_train.py \
--seed 1234 \
--batch_size 512 \
--model resnet18 \
--dataset cifar10 \
--mem_size $MEM_SIZE \
--epochs 100 \
--start_epoch 500 \
--learning_rate 0.5 \
--temperature 0.5 \
--current_temp 0.2 \
--past_temp 0.01 \
--current_temp_sprd 0.2 \
--past_temp_sprd 0.1 \
--cosine \
--num_workers 16 \
--wandb \
--wandb_project_name your_project_name \
--wandb_entity your_entity \
--job_run_name tanccl-samix-cf00-m-${MEM_SIZE} \
--distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \
--loss_normal_samples dr \
--weight_samix_loss 5.0 \
--filter_distillation_point \
--samix \
--predictor_hidden_dim 128
python3 -W ignore main_train.py \
--seed 1234 \
--batch_size 512 \
--model resnet18 \
--dataset cifar100 \
--mem_size $MEM_SIZE \
--epochs 100 \
--start_epoch 500 \
--learning_rate 0.5 \
--temperature 0.5 \
--current_temp 0.2 \
--past_temp 0.01 \
--current_temp_sprd 0.2 \
--past_temp_sprd 0.1 \
--cosine \
--num_workers 16 \
--wandb \
--wandb_project_name your_project_name \
--wandb_entity your_entity \
--job_run_name tanccl-samix-cf100-m-${MEM_SIZE} \
--distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \
--loss_normal_samples dr \
--weight_samix_loss 5.0 \
--filter_distillation_point \
--samix \
--predictor_hidden_dim 128
python3 -W ignore main_train.py \
--seed 1234 \
--batch_size 512 \
--model resnet18 \
--dataset tiny-imagenet \
--mem_size $MEM_SIZE \
--epochs 50 \
--start_epoch 500 \
--learning_rate 0.1 \
--temperature 0.5 \
--current_temp 0.1 \
--past_temp 0.1 \
--current_temp_sprd 0.2 \
--past_temp_sprd 0.1 \
--cosine \
--num_workers 16 \
--wandb \
--wandb_project_name your_project_name \
--wandb_entity your_entity \
--job_run_name tanccl-samix-tiny-imagenet-m-${MEM_SIZE} \
--distillation hsd \
--log_folder_zero_mem ${LOG_FOLDER_ZERO_MEM} \
--loss nc_samix \
--loss_normal_samples dr \
--weight_samix_loss 5.0 \
--filter_distillation_point \
--samix \
--predictor_hidden_dim 256
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment