Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MixMatch - What is the reason for only a single lambda for all mixing samples? #69

Open
barskern opened this issue Apr 13, 2023 · 0 comments

Comments

@barskern
Copy link

barskern commented Apr 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant