### Run Training and Evaluation Scripts Source: https://github.com/hobbitlong/supcontrast/blob/master/README.md Command-line examples for running standard cross-entropy, supervised contrastive pretraining, linear evaluation, and custom dataset training. ```bash python main_ce.py --batch_size 1024 \ --learning_rate 0.8 \ --cosine --syncBN \ ``` ```bash python main_supcon.py --batch_size 1024 \ --learning_rate 0.5 \ --temp 0.1 \ --cosine ``` ```bash python main_linear.py --batch_size 512 \ --learning_rate 5 \ --ckpt /path/to/model.pth ``` ```bash python main_supcon.py --batch_size 1024 \ --learning_rate 0.5 \ --temp 0.5 \ --cosine --syncBN \ --method SimCLR ``` ```bash python main_linear.py --batch_size 512 \ --learning_rate 1 \ --ckpt /path/to/model.pth ``` ```bash python main_supcon.py --batch_size 1024 \ --learning_rate 0.5 \ --temp 0.1 --cosine \ --dataset path \ --data_folder ./path \ --mean "(0.4914, 0.4822, 0.4465)" \ --std "(0.2675, 0.2565, 0.2761)" \ --method SimCLR ``` -------------------------------- ### Initialize and Use SupConLoss Source: https://github.com/hobbitlong/supcontrast/blob/master/README.md Demonstrates how to import, initialize, and apply the SupConLoss function for both supervised contrastive learning and SimCLR. ```python from losses import SupConLoss # define loss with a temperature `temp` criterion = SupConLoss(temperature=temp) # features: [bsz, n_views, f_dim] # `n_views` is the number of crops from each image # better be L2 normalized in f_dim dimension features = ... # labels: [bsz] labels = ... # SupContrast loss = criterion(features, labels) # or SimCLR loss = criterion(features) ... ``` -------------------------------- ### BibTeX Reference Source: https://github.com/hobbitlong/supcontrast/blob/master/README.md Citation information for the Supervised Contrastive Learning paper. ```bibtex @Article{khosla2020supervised, title = {Supervised Contrastive Learning}, author = {Prannay Khosla and Piotr Teterwak and Chen Wang and Aaron Sarna and Yonglong Tian and Phillip Isola and Aaron Maschinot and Ce Liu and Dilip Krishnan}, journal = {arXiv preprint arXiv:2004.11362}, year = {2020}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.