#hide from nbdev.showdoc import * import timm import torch import torch.nn.functional as F from timm.loss import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy from timm.data.mixup import mixup_target x = torch.eye(2) x_i = 1 - x y = torch.arange(2) LabelSmoothingCrossEntropy(0.0)(x,y),LabelSmoothingCrossEntropy(0.0)(x_i,y) LabelSmoothingCrossEntropy(0.1)(x,y),LabelSmoothingCrossEntropy(0.1)(x_i,y) x=torch.tensor([[[0,1.,0,0,1.]],[[1.,1.,1.,1.,1.]]],device='cuda') y=mixup_target(torch.tensor([1,4],device='cuda'),5, lam=0.7) x,y SoftTargetCrossEntropy()(x[0],y),SoftTargetCrossEntropy()(x[1],y) #hide from nbdev.export import notebook2script notebook2script()