Skip to content

Commit bdbcbaa

Browse files
Update beta sampling code in augment.py
The function `_sample_from_beta(alpha, beta, shape)` in `MixupAndCutmix` class, is not having the same functionality as `numpy.random.beta`. So `tfm.vision.augment.MixupAndCutmix._sample_from_beta(0.2, 0.2, tf.shape( tf.range(10000))).numpy()` is also deviating as well. So suggesting the fix keeping `alpha=alpha, beta=1.0` in `_sample_from_beta`. The reproduced [gist](https://colab.sandbox.google.com/gist/LakshmiKalaKadali/06533824610d6e85ea4aa3c6399819e6/tf_model_13490.ipynb#scrollTo=zSlE-3YDjL91) also attached. This PR closes [#13490](#13490) Thank You
1 parent 3d5e05f commit bdbcbaa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: official/vision/ops/augment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2697,8 +2697,8 @@ def distort(self, images: tf.Tensor,
26972697

26982698
@staticmethod
26992699
def _sample_from_beta(alpha, beta, shape):
2700-
sample_alpha = tf.random.gamma(shape, 1., beta=alpha)
2701-
sample_beta = tf.random.gamma(shape, 1., beta=beta)
2700+
sample_alpha = tf.random.gamma(shape, alpha, beta=1.0)
2701+
sample_beta = tf.random.gamma(shape, alpha, beta=1.0)
27022702
return sample_alpha / (sample_alpha + sample_beta)
27032703

27042704
def _cutmix(self, images: tf.Tensor,

0 commit comments

Comments
 (0)