MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / one_hot

Function one_hot

models/mixmatch/mixmatch_utils.py:18–20  ·  view source on GitHub ↗
(targets, nClass, gpu)

Source from the content-addressed store, hash-verified

16
17
18def one_hot(targets, nClass, gpu):
19 logits = torch.zeros(targets.size(0), nClass).cuda(gpu)
20 return logits.scatter_(1, targets.unsqueeze(1), 1)
21
22
23def mixup_one_target(x, y, gpu, alpha=1.0, is_bias=False):

Callers 1

trainMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected