Skip to content

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

Description

@barskern

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions