Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhihan-Zhou committed May 30, 2022
1 parent 32edab5 commit 6a943c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ python train.py SimCLR --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 5

- BCL-I
```train BCL-I
python train.py BCL_I --bcl --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 5e-4 --data_folder ${data_folder} --trainSplit cifar100_imbSub_with_subsets/cifar100_split1_D_i.npy
python train.py BCL_I --bcl --rand_k 1 --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 5e-4 --data_folder ${data_folder} --trainSplit cifar100_imbSub_with_subsets/cifar100_split1_D_i.npy
```

- SDCLR
```train SimCLR
```train SDCLR
python train_sdclr.py SDCLR --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 1e-4 --data_folder ${data_folder} --trainSplit cifar100_imbSub_with_subsets/cifar100_split1_D_i.npy
```

- BCL-D
```train BCL-D
python train_sdclr.py BCL_D --bcl --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 1e-4 --data_folder ${data_folder} --trainSplit cifar100_imbSub_with_subsets/cifar100_split1_D_i.npy
python train_sdclr.py BCL_D --bcl --rand_k 2 --lr 0.5 --epochs 2000 --temperature 0.2 --weight_decay 1e-4 --data_folder ${data_folder} --trainSplit cifar100_imbSub_with_subsets/cifar100_split1_D_i.npy
```

Pretrained checkpoints will be saved in 'checkpoints/'.
Expand All @@ -135,6 +135,19 @@ python test.py --checkpoint ${checkpoint_pretrain} --prune --test_fullshot --tes

The code will output the results of full-shot/100-shot/50-shot linear probing evaluation.

### Results and Pretrained Models

We provide the full-shot/100-shot/50-shot results(demo) pretrained on 'cifar100_split1_D_i.npy' with the corresponding checkpoint weights.

| Method | Full-shot | 100-shot | 50-shot | Model |
| ---------------------- |:-----:|:------:|:------: |:------:|
| SimCLR | 50.7 | 46.3 | 42.4 | [ResNet18](https://drive.google.com/file/d/1gcVzeLDY1fCR1uUjwlrYyatByb3AP74W/view?usp=sharing)|
| SDCLR | 55.0 | 49.7 | 45.6 | [ResNet18](https://drive.google.com/file/d/1MHH8K8mmCCPL6GOwR9g0TtjSJPPouRBZ/view?usp=sharing)|
| BCL-I | | | | [ResNet18]
| BCL-D | | | | [ResNet18]

After downloading the checkpoints, you could run evaluation by the instructions in the evaluating section.

### Extensions

**Steps to Implement Your Own Model**
Expand Down
6 changes: 4 additions & 2 deletions data/memoboosted_cifar100.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ def __getitem__(self, idx):
img = self.data[idx]
img = Image.fromarray(img).convert('RGB')

min_strength = 10 # training stability
memo_boosted_aug = transforms.Compose([
transforms.RandomResizedCrop(32, scale=(0.1, 1.0), interpolation=3),
transforms.RandomHorizontalFlip(),
transforms.RandomApply([transforms.ColorJitter(0.4, 0.4, 0.4, 0.1)], p=0.8),
transforms.RandomGrayscale(p=0.2),
# RandAugment_prob(1, 23, 0.5),
# RandAugment_prob(1, 30*self.momentum_weight[idx]*np.random.rand(1), 1.0*self.momentum_weight[idx]),
RandAugment_prob(1, 5+25*self.momentum_weight[idx]*np.random.rand(1), 1.0*self.momentum_weight[idx]),
# RandAugment_prob(self.args.rand_k, self.args.rand_strength*self.momentum_weight[idx]*np.random.rand(1), 1.0*self.momentum_weight[idx]),
# RandAugment_prob(1, 10+20*self.momentum_weight[idx]*np.random.rand(1), 1.0*self.momentum_weight[idx]),
RandAugment_prob(self.args.rand_k, min_strength + (self.args.rand_strength - min_strength)*self.momentum_weight[idx]*np.random.rand(1), 1.0*self.momentum_weight[idx]),
transforms.ToTensor(),
])

Expand Down

0 comments on commit 6a943c7

Please sign in to comment.