|
def mixup_one_target(x, y, gpu, alpha=1.0, is_bias=False): |
|
"""Returns mixed inputs, mixed targets, and lambda |
|
""" |
|
if alpha > 0: |
|
lam = np.random.beta(alpha, alpha) |
|
else: |
|
lam = 1 |
|
if is_bias: |
|
lam = max(lam, 1 - lam) |
|
|
|
index = torch.randperm(x.size(0)).cuda(gpu) |
|
|
|
mixed_x = lam * x + (1 - lam) * x[index] |
|
mixed_y = lam * y + (1 - lam) * y[index] |
|
return mixed_x, mixed_y, lam |
In the code snippet above, a single lam parameter is selected for all mix-up operations. In google's implementation of MixMatch they sample a beta distribution individually for each sample (see code below). Is there a reason for the choice to only sample the beta distribution once here?
https://github.com/google-research/mixmatch/blob/1011a1d51eaa9ca6f5dba02096a848d1fe3fc38e/libml/layers.py#L166-L175
TorchSSL/models/mixmatch/mixmatch_utils.py
Lines 23 to 37 in b45c3b3
In the code snippet above, a single
lamparameter is selected for all mix-up operations. In google's implementation of MixMatch they sample a beta distribution individually for each sample (see code below). Is there a reason for the choice to only sample the beta distribution once here?https://github.com/google-research/mixmatch/blob/1011a1d51eaa9ca6f5dba02096a848d1fe3fc38e/libml/layers.py#L166-L175