mirror of
https://github.com/huggingface/pytorch-image-models.git
synced 2025-06-03 15:01:08 +08:00
Replace deprecated NumPy aliases of builtin types
This commit is contained in:
parent
c241081251
commit
158bf129c4
@ -120,7 +120,7 @@ class Mixup:
|
|||||||
|
|
||||||
def _params_per_elem(self, batch_size):
|
def _params_per_elem(self, batch_size):
|
||||||
lam = np.ones(batch_size, dtype=np.float32)
|
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_enabled:
|
||||||
if self.mixup_alpha > 0. and self.cutmix_alpha > 0.:
|
if self.mixup_alpha > 0. and self.cutmix_alpha > 0.:
|
||||||
use_cutmix = np.random.rand(batch_size) < self.switch_prob
|
use_cutmix = np.random.rand(batch_size) < self.switch_prob
|
||||||
@ -131,7 +131,7 @@ class Mixup:
|
|||||||
elif self.mixup_alpha > 0.:
|
elif self.mixup_alpha > 0.:
|
||||||
lam_mix = np.random.beta(self.mixup_alpha, self.mixup_alpha, size=batch_size)
|
lam_mix = np.random.beta(self.mixup_alpha, self.mixup_alpha, size=batch_size)
|
||||||
elif self.cutmix_alpha > 0.:
|
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)
|
lam_mix = np.random.beta(self.cutmix_alpha, self.cutmix_alpha, size=batch_size)
|
||||||
else:
|
else:
|
||||||
assert False, "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."
|
assert False, "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."
|
||||||
|
@ -301,8 +301,8 @@ def rand_bbox(size, lam, scale=1):
|
|||||||
W = size[1] // scale
|
W = size[1] // scale
|
||||||
H = size[2] // scale
|
H = size[2] // scale
|
||||||
cut_rat = np.sqrt(1. - lam)
|
cut_rat = np.sqrt(1. - lam)
|
||||||
cut_w = np.int(W * cut_rat)
|
cut_w = (W * cut_rat).astype(int)
|
||||||
cut_h = np.int(H * cut_rat)
|
cut_h = (H * cut_rat).astype(int)
|
||||||
|
|
||||||
# uniform
|
# uniform
|
||||||
cx = np.random.randint(W)
|
cx = np.random.randint(W)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user