Callbacks that perform data augmentation by mixing samples in different ways.

class MixHandler1d[source]

MixHandler1d(alpha=0.5) :: Callback

A handler class for implementing mixed sample data augmentation

class MixUp1d[source]

MixUp1d(alpha=0.4) :: MixHandler1d

Implementation of https://arxiv.org/abs/1710.09412

from tsai.models.utils import *
from tsai.models.ResNet import *
from tsai.learner import *
dsid = 'NATOPS'
X, y, splits = get_UCR_data(dsid, return_split=False)
tfms = [None, Categorize()]
batch_tfms = TSStandardize()
dls = get_ts_dls(X, y, tfms=tfms, splits=splits, batch_tfms=batch_tfms)
model = build_model(ResNet, dls=dls)
learn = Learner(dls, model, cbs=MixUp1d(0.4))
learn.fit_one_cycle(1)
epoch train_loss valid_loss time
0 1.814203 1.782917 00:03

class CutMix1d[source]

CutMix1d(alpha=1.0) :: MixHandler1d

Implementation of https://arxiv.org/abs/1905.04899

dsid = 'NATOPS'
X, y, splits = get_UCR_data(dsid, return_split=False)
tfms = [None, Categorize()]
batch_tfms = TSStandardize()
dls = get_ts_dls(X, y, tfms=tfms, splits=splits, batch_tfms=batch_tfms)
model = build_model(ResNet, dls=dls)
learn = Learner(dls, model, cbs=CutMix1d(1.))
learn.fit_one_cycle(1)
epoch train_loss valid_loss time
0 1.795043 1.738316 00:03
dsid = 'NATOPS'
X, y, splits = get_UCR_data(dsid, return_split=False)
batch_tfms = TSStandardize()
dls = get_ts_dls(X, splits=splits, batch_tfms=batch_tfms)
model = build_model(ResNet, dls=dls)
learn = Learner(dls, model, loss_func=MSELossFlat(), cbs=CutMix1D(1.))
learn.fit_one_cycle(1)
epoch train_loss valid_loss time
0 nan None 00:01