EVA-02
pretrain
def compute_loss(output, label):
loss_func = nn.CosineSimilarity(dim=-1)
loss = loss_func(output.float(), label.float())
return -loss.mean()
finetune
if mixup_fn is not None:
# smoothing is handled with mixup label transform
criterion = SoftTargetCrossEntropy()
elif args.smoothing > 0.:
criterion = LabelSmoothingCrossEntropy(smoothing=args.smoothing)
else:
criterion = torch.nn.CrossEntropyLoss() # linear
info-NCE loss