Skip to content

Commit

Permalink
fix online knn on STL10 (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonkeyShot21 authored Dec 1, 2021
1 parent 95886b6 commit 0ac7b8f
Show file tree
Hide file tree
Showing 83 changed files with 267 additions and 253 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ While the library is self-contained, it is possible to use the models outside of
* Increased data processing speed by up to 100% using [Nvidia Dali](https://github.com/NVIDIA/DALI).
* Asymmetric and symmetric augmentations.
### Evaluation and logging
* Online linear evaluation via stop-gradient for easier debugging and prototyping (optionally available for the momentum encoder as well).
* Online linear evaluation via stop-gradient for easier debugging and prototyping (optionally available for the momentum backbone as well).
* Online Knn evaluation.
* Normal offline linear evaluation.
* All the perks of PyTorch Lightning (mixed precision, gradient accumulation, clipping, automatic logging and much more).
Expand Down Expand Up @@ -119,7 +119,7 @@ pip3 install .

## Training

For pretraining the encoder, follow one of the many bash files in `bash_files/pretrain/`.
For pretraining the backbone, follow one of the many bash files in `bash_files/pretrain/`.

After that, for offline linear evaluation, follow the examples on `bash_files/linear`.

Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/barlow_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/byol_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/deepclusterv2_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /data/datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/dino_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/general_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/mocov2plus_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/nnclr_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/ressl_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/test \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/simclr_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /data/datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/simsiam_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/swav_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /data/datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/vibcreg_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet-100/vicreg_linear.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/linear/imagenet/byol.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_linear.py \
--dataset imagenet \
--encoder resnet50 \
--backbone resnet50 \
--data_dir /datasets \
--train_dir ILSVRC2012/train \
--val_dir ILSVRC2012/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/barlow.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/byol.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/deepclusterv2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/dino.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/mocov2plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/nnbyol.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/nnclr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/nnsiam.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/ressl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/simclr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/simsiam.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/swav.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/vibcreg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/vicreg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/cifar/wmse.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset $1 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir ./datasets \
--max_epochs 1000 \
--gpus 0 \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/custom/byol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --dali flag is also supported
python3 ../../../main_pretrain.py \
--dataset custom \
--encoder resnet18 \
--backbone resnet18 \
--data_dir PATH_TO_DIR \
--train_dir PATH_TO_TRAIN_DIR \
--no_labels \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/barlow.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/byol.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/deepclusterv2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/dino.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/dino_vit.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder vit_tiny \
--backbone vit_tiny \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/test \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/mocov2plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/multicrop/byol.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# multicrop byol
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/nnclr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/ressl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
6 changes: 3 additions & 3 deletions bash_files/pretrain/imagenet-100/simclr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down Expand Up @@ -37,7 +37,7 @@ python3 ../../../main_pretrain.py \

python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down Expand Up @@ -75,7 +75,7 @@ python3 ../../../main_pretrain.py \

python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/simsiam.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/swav.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/vibcreg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/vicreg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/val \
Expand Down
2 changes: 1 addition & 1 deletion bash_files/pretrain/imagenet-100/wmse.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python3 ../../../main_pretrain.py \
--dataset imagenet100 \
--encoder resnet18 \
--backbone resnet18 \
--data_dir /datasets \
--train_dir imagenet-100/train \
--val_dir imagenet-100/test \
Expand Down
Loading

0 comments on commit 0ac7b8f

Please sign in to comment.