(x, y, alpha, device)
return mixed_x, y_a, y_b, lam
Returns mixed inputs, pairs of targets, and lambda
Returns mixed inputs, pairs of targets, and lambda
Returns mixed inputs pairs of targets and lambda
def mixup_data(x, y, alpha, device):
    """Returns mixed inputs, pairs of targets, and lambda"""
    if alpha > 0:
        lam = np.random.beta(alpha, alpha)
    else:
        lam = 1

    batch_size = x.size()[0]
    index = torch.randperm(batch_size).to(device)

    mixed_x = lam * x + (1 - lam) * x[index, :]
    y_a, y_b = y, y[index]
    return mixed_x, y_a, y_b, lam
def mixup_data ( x , y , alpha , device ) : if alpha > 0 : lam = np . random . beta ( alpha , alpha ) else : lam = 1 batch_size = x . size ( ) [ 0 ] index = torch . randperm ( batch_size ) . to ( device ) mixed_x = lam * x + ( 1 - lam ) * x [ index , : ] y_a , y_b = y , y [ index ] return mixed_x , y_a , y_b , lam