Skip to content

Commit 394e814

Browse files
authored
Merge pull request #1866 from lRomul/replace_deprecated_np_types
Replace deprecated NumPy aliases of builtin types
2 parents c241081 + 158bf12 commit 394e814

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

timm/data/mixup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self, mixup_alpha=1., cutmix_alpha=0., cutmix_minmax=None, prob=1.0
120120

121121
def _params_per_elem(self, batch_size):
122122
lam = np.ones(batch_size, dtype=np.float32)
123-
use_cutmix = np.zeros(batch_size, dtype=np.bool)
123+
use_cutmix = np.zeros(batch_size, dtype=bool)
124124
if self.mixup_enabled:
125125
if self.mixup_alpha > 0. and self.cutmix_alpha > 0.:
126126
use_cutmix = np.random.rand(batch_size) < self.switch_prob
@@ -131,7 +131,7 @@ def _params_per_elem(self, batch_size):
131131
elif self.mixup_alpha > 0.:
132132
lam_mix = np.random.beta(self.mixup_alpha, self.mixup_alpha, size=batch_size)
133133
elif self.cutmix_alpha > 0.:
134-
use_cutmix = np.ones(batch_size, dtype=np.bool)
134+
use_cutmix = np.ones(batch_size, dtype=bool)
135135
lam_mix = np.random.beta(self.cutmix_alpha, self.cutmix_alpha, size=batch_size)
136136
else:
137137
assert False, "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."

timm/models/volo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ def rand_bbox(size, lam, scale=1):
301301
W = size[1] // scale
302302
H = size[2] // scale
303303
cut_rat = np.sqrt(1. - lam)
304-
cut_w = np.int(W * cut_rat)
305-
cut_h = np.int(H * cut_rat)
304+
cut_w = (W * cut_rat).astype(int)
305+
cut_h = (H * cut_rat).astype(int)
306306

307307
# uniform
308308
cx = np.random.randint(W)

0 commit comments

Comments
 (0)