Skip to content

Commit

Permalink
comment out cutmix in hlb_cifar (tinygrad#3201)
Browse files Browse the repository at this point in the history
it's no-op with multi gpu and less STEPS. also the patch was selected from the whole dataset, not from the same batch
  • Loading branch information
chenyuxyz authored Jan 22, 2024
1 parent e6c71f1 commit 836883f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/hlb_cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ def cutmix(X:Tensor, Y:Tensor, mask_size=3):
mask = make_square_mask(X.shape, mask_size)
order = list(range(0, X.shape[0]))
random.shuffle(order)
# NOTE: Memory access fault if use getitem directly
X_patch = Tensor(X.numpy()[order,...])
Y_patch = Tensor(Y.numpy()[order])
X_cutmix = Tensor.where(mask, X_patch, X)
Expand All @@ -208,7 +207,8 @@ def fetch_batches(X_in:Tensor, Y_in:Tensor, BS:int, is_train:bool):
if is_train:
X = random_crop(X, crop_size=32)
X = Tensor.where(Tensor.rand(X.shape[0],1,1,1) < 0.5, X[..., ::-1], X) # flip LR
if step >= hyp['net']['cutmix_steps']: X, Y = cutmix(X, Y, mask_size=hyp['net']['cutmix_size'])
# NOTE: to bring cutmix back, make sure it's performing on mini-batch and not the whole set
# if step >= hyp['net']['cutmix_steps']: X, Y = cutmix(X, Y, mask_size=hyp['net']['cutmix_size'])
X, Y = X.numpy(), Y.numpy()
et = time.monotonic()
print(f"shuffling {'training' if is_train else 'test'} dataset in {(et-st)*1e3:.2f} ms ({cnt})")
Expand Down

0 comments on commit 836883f

Please sign in to comment.