mixup: mixup Function

View source: R/mixup.R

mixupR Documentation

mixup Function

Description

This function enlarges training sets using linear interpolations of features and associated labels as described in https://arxiv.org/abs/1710.09412.

An R package inspired by mixup: Beyond Empirical Risk Minimization

Usage

mixup(x1, y1, alpha = 1, concat = FALSE, batch_size = NULL)

Arguments

x1

Original features

y1

Original labels

alpha

Hyperparameter specifying strength of interpolation

concat

Concatenate mixup data with original

batch_size

How many mixup values to produce

Details

The x1 and y1 parameters must be numeric and must have equal numbers of examples. Non-finite values are not permitted. Factors should be one-hot encoded.

For now, only binary classification is supported. Meaning y1 must contain only numeric 0 and 1 values.

Alpha values must be greater than or equal to zero. Alpha equal to zero specifies no interpolation.

The mixup function returns a two-element list containing interpolated x and y values. Optionally, the original values can be concatenated with the new values.

Value

A list containing interpolated x and y values and optionally the original values

Interpolation

This package enlarges training sets using linear interpolations of features and associated labels:

x' = λ * x_i + (1 - λ) * x_j, where x_i, x_j are raw input vectors

y' = λ * y_i + (1 - λ) * y_j, where y_i, y_j are one-hot label encodings

(x_i, y_i) and (x_j ,y_j) are two examples drawn at random from the training data, and λ \in [0, 1] with λ \sim Beta(α, α) for α \in (0, ∞). The mixup hyper-parameter α controls the strength of interpolation between feature-target pairs.

Examples

# Use builtin mtcars dataset with mtcars$am (automatic/manual) as binary target
data(mtcars)
mtcars.mix <- mixup(mtcars[, -9], mtcars$am)

makeyourownmaker/mixup documentation built on Sept. 14, 2022, 8:51 a.m.