Esempio n. 1
0
    def process_train(self, *args):
        super(MixupAcc, self).process_train(*args)
        state = args[0]

        target1, target2 = state[torchbearer.Y_TRUE]
        _state = args[0].copy()
        _state[torchbearer.Y_TRUE] = target1
        acc1 = self.cat_acc.process(_state)

        _state = args[0].copy()
        _state[torchbearer.Y_TRUE] = target2
        acc2 = self.cat_acc.process(_state)

        return acc1 * state[torchbearer.MIXUP_LAMBDA] + acc2 * (
            1 - state[torchbearer.MIXUP_LAMBDA])
Esempio n. 2
0
 def __init__(self, alpha=1.0, lam=RANDOM):
     super(Mixup, self).__init__()
     self.alpha = alpha
     self.lam = lam
     self.distrib = Beta(self.alpha, self.alpha)
Esempio n. 3
0
    def process_validate(self, *args):
        super(MixupAcc, self).process_validate(*args)

        return self.cat_acc.process(*args)
Esempio n. 4
0
 def __init__(self):
     super(MixupAcc, self).__init__('mixup_acc')
     self.cat_acc = CategoricalAccuracy().root