Commit 7214e17e authored by A. Unique TensorFlower's avatar A. Unique TensorFlower
Browse files

Internal change

PiperOrigin-RevId: 430245113
parent 0967769d
...@@ -2259,7 +2259,7 @@ class MixupAndCutmix: ...@@ -2259,7 +2259,7 @@ class MixupAndCutmix:
labels: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]: labels: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
"""Apply cutmix.""" """Apply cutmix."""
lam = MixupAndCutmix._sample_from_beta(self.cutmix_alpha, self.cutmix_alpha, lam = MixupAndCutmix._sample_from_beta(self.cutmix_alpha, self.cutmix_alpha,
labels.shape) tf.shape(labels))
ratio = tf.math.sqrt(1 - lam) ratio = tf.math.sqrt(1 - lam)
...@@ -2293,7 +2293,7 @@ class MixupAndCutmix: ...@@ -2293,7 +2293,7 @@ class MixupAndCutmix:
def _mixup(self, images: tf.Tensor, def _mixup(self, images: tf.Tensor,
labels: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]: labels: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
lam = MixupAndCutmix._sample_from_beta(self.mixup_alpha, self.mixup_alpha, lam = MixupAndCutmix._sample_from_beta(self.mixup_alpha, self.mixup_alpha,
labels.shape) tf.shape(labels))
lam = tf.reshape(lam, [-1, 1, 1, 1]) lam = tf.reshape(lam, [-1, 1, 1, 1])
lam_cast = tf.cast(lam, dtype=images.dtype) lam_cast = tf.cast(lam, dtype=images.dtype)
images = lam_cast * images + (1. - lam_cast) * tf.reverse(images, [0]) images = lam_cast * images + (1. - lam_cast) * tf.reverse(images, [0])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment