MCPcopy Create free account
hub / github.com/geekcomputers/Python / __call__

Method __call__

ML/src/python/neuralforge/data/transforms.py:34–46  ·  view source on GitHub ↗
(self, batch)

Source from the content-addressed store, hash-verified

32 self.alpha = alpha
33
34 def __call__(self, batch):
35 if self.alpha > 0:
36 lam = torch.distributions.Beta(self.alpha, self.alpha).sample()
37 else:
38 lam = 1.0
39
40 batch_size = batch[0].size(0)
41 index = torch.randperm(batch_size)
42
43 mixed_input = lam * batch[0] + (1 - lam) * batch[0][index, :]
44 y_a, y_b = batch[1], batch[1][index]
45
46 return mixed_input, y_a, y_b, lam
47
48class RandomCutmix:
49 def __init__(self, alpha: float = 1.0):

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected