From df31d808fcd13ef7840e6d7682150ddc5eab1628 Mon Sep 17 00:00:00 2001 From: Yang Nie Date: Thu, 2 Mar 2023 03:47:41 +0800 Subject: [PATCH] bugfix: MixupOperator, CutmixOperator, FmixOperator --- ppcls/data/preprocess/batch_ops/batch_operators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ppcls/data/preprocess/batch_ops/batch_operators.py b/ppcls/data/preprocess/batch_ops/batch_operators.py index c9563e229..cdcee0625 100644 --- a/ppcls/data/preprocess/batch_ops/batch_operators.py +++ b/ppcls/data/preprocess/batch_ops/batch_operators.py @@ -88,7 +88,7 @@ class MixupOperator(BatchOperator): def __call__(self, batch): imgs, labels, bs = self._unpack(batch) - idx = np.random.permutation(bs) + idx = np.arange(bs)[::-1] lam = np.random.beta(self._alpha, self._alpha) imgs = lam * imgs + (1 - lam) * imgs[idx] targets = self._mix_target(labels, labels[idx], lam) @@ -143,7 +143,7 @@ class CutmixOperator(BatchOperator): def __call__(self, batch): imgs, labels, bs = self._unpack(batch) - idx = np.random.permutation(bs) + idx = np.arange(bs)[::-1] lam = np.random.beta(self._alpha, self._alpha) bbx1, bby1, bbx2, bby2 = self._rand_bbox(imgs.shape, lam) @@ -179,7 +179,7 @@ class FmixOperator(BatchOperator): def __call__(self, batch): imgs, labels, bs = self._unpack(batch) - idx = np.random.permutation(bs) + idx = np.arange(bs)[::-1] size = (imgs.shape[2], imgs.shape[3]) lam, mask = sample_mask(self._alpha, self._decay_power, \ size, self._max_soft, self._reformulate)