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

Function create_k_shot_mask

code/utils.py:436–446  ·  view source on GitHub ↗
(labels, args)

Source from the content-addressed store, hash-verified

434 return loss
435
436def create_k_shot_mask(labels, args):
437 k = args.shot
438 unique_classes = torch.unique(labels)
439 k_shot_mask = torch.zeros_like(labels, dtype=torch.bool)
440
441 for cls in unique_classes:
442 class_indices = (labels == cls).nonzero(as_tuple=True)[0]
443 chosen_indices = class_indices[torch.randperm(len(class_indices))[:k]]
444 k_shot_mask[chosen_indices] = True
445
446 return k_shot_mask
447
448
449

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected