From 5ccb892ae59cbe183ef91c1648751ff0085cc0da Mon Sep 17 00:00:00 2001 From: Jordan Gong Date: Sat, 20 Aug 2022 10:45:04 +0800 Subject: Add label smoothing option --- simclr/evaluate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'simclr') diff --git a/simclr/evaluate.py b/simclr/evaluate.py index 91395d1..f18c417 100644 --- a/simclr/evaluate.py +++ b/simclr/evaluate.py @@ -43,6 +43,8 @@ def parse_args_and_config(): parser.add_argument('--encoder', default='resnet', type=str, choices=('resnet', 'vit'), help='Backbone of encoder') + parser.add_argument('--label-smooth', default=0., type=float, + help='Label smoothing in cross entropy') parser.add_argument('--hid-dim', default=2048, type=int, help='Number of dimension of embedding') parser.add_argument('--out-dim', default=128, type=int, @@ -280,4 +282,5 @@ if __name__ == '__main__': ) loggers = trainer.init_logger(args.log_dir) - trainer.train(args.num_iters, torch.nn.CrossEntropyLoss(), loggers, device) + loss_fn = torch.nn.CrossEntropyLoss(label_smoothing=args.label_smooth) + trainer.train(args.num_iters, loss_fn, loggers, device) -- cgit v1.2.3