Replace deprecated NumPy aliases of builtin types

This commit is contained in:
Ruslan Baikulov 2023-07-03 22:24:25 +03:00
parent c241081251
commit 158bf129c4
2 changed files with 4 additions and 4 deletions

View File

@ -120,7 +120,7 @@ class Mixup:
def _params_per_elem(self, batch_size):
lam = np.ones(batch_size, dtype=np.float32)
use_cutmix = np.zeros(batch_size, dtype=np.bool)
use_cutmix = np.zeros(batch_size, dtype=bool)
if self.mixup_enabled:
if self.mixup_alpha > 0. and self.cutmix_alpha > 0.:
use_cutmix = np.random.rand(batch_size) < self.switch_prob
@ -131,7 +131,7 @@ class Mixup:
elif self.mixup_alpha > 0.:
lam_mix = np.random.beta(self.mixup_alpha, self.mixup_alpha, size=batch_size)
elif self.cutmix_alpha > 0.:
use_cutmix = np.ones(batch_size, dtype=np.bool)
use_cutmix = np.ones(batch_size, dtype=bool)
lam_mix = np.random.beta(self.cutmix_alpha, self.cutmix_alpha, size=batch_size)
else:
assert False, "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."

View File

@ -301,8 +301,8 @@ def rand_bbox(size, lam, scale=1):
W = size[1] // scale
H = size[2] // scale
cut_rat = np.sqrt(1. - lam)
cut_w = np.int(W * cut_rat)
cut_h = np.int(H * cut_rat)
cut_w = (W * cut_rat).astype(int)
cut_h = (H * cut_rat).astype(int)
# uniform
cx = np.random.randint(W)