(x, y, batch_size, alpha=1.0)
return mixed_x.astype('float32'), y_a.astype('int64'),\
           y_b.astype('int64'), np.array(lam, dtype='float32')
Compute the mixup data. Return mixed inputs, pairs of targets, and lambda
Compute the mixup data. Return mixed inputs, pairs of targets, and lambda
Compute the mixup data . Return mixed inputs pairs of targets and lambda
def mixup_data(x, y, batch_size, alpha=1.0):
    '''Compute the mixup data. Return mixed inputs, pairs of targets, and lambda'''
    if alpha > 0.:
        lam = np.random.beta(alpha, alpha)
    else:
        lam = 1.
    index = np.random.permutation(batch_size)

    mixed_x = lam * x + (1 - lam) * x[index, :]
    y_a, y_b = y, y[index]
    return mixed_x.astype('float32'), y_a.astype('int64'),\
           y_b.astype('int64'), np.array(lam, dtype='float32')
def mixup_data ( x , y , batch_size , alpha = 1.0 ) : if alpha > 0. : lam = np . random . beta ( alpha , alpha ) else : lam = 1. index = np . random . permutation ( batch_size ) mixed_x = lam * x + ( 1 - lam ) * x [ index , : ] y_a , y_b = y , y [ index ] return mixed_x . astype ( 'float32' ) , y_a . astype ( 'int64' ) , y_b . astype ( 'int64' ) , np . array ( lam , dtype = 'float32' )