MCPcopy Create free account
hub / github.com/NineAbyss/ZeroG / sce_loss

Function sce_loss

code/utils.py:424–434  ·  view source on GitHub ↗
(x, y, alpha=3)

Source from the content-addressed store, hash-verified

422 return CL_loss, CL_acc
423
424def sce_loss(x, y, alpha=3):
425 x = F.normalize(x, p=2, dim=-1)
426 y = F.normalize(y, p=2, dim=-1)
427
428 # loss = - (x * y).sum(dim=-1)
429 # loss = (x_h - y_h).norm(dim=1).pow(alpha)
430
431 loss = (1 - (x * y).sum(dim=-1)).pow_(alpha)
432
433 loss = loss.mean()
434 return loss
435
436def create_k_shot_mask(labels, args):
437 k = args.shot

Callers 1

get_lossMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected