Skip to content

Conversation

@LakshmiKalaKadali
Copy link
Collaborator

@LakshmiKalaKadali LakshmiKalaKadali commented Jan 30, 2025

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 gistalso attached.

This PR closes #13490

Thank You

Description

📝 Please include a summary of the change.

  • Please also include relevant motivation and context.
  • List any dependencies that are required for this change.

Type of change

For a new feature or function, please create an issue first to discuss it
with us before submitting a pull request.

Note: Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • TensorFlow 2 migration
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • A new research paper code implementation
  • Other (Specify)

Tests

📝 Please describe the tests that you ran to verify your changes.

  • Provide instructions so we can reproduce.
  • Please also list any relevant details for your test configuration.

Test Configuration:

Checklist

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
@LakshmiKalaKadali LakshmiKalaKadali added the models:official models that come under official repository label Feb 3, 2025
@laxmareddyp laxmareddyp added the ready to pull ready to pull (create internal pr review and merge automatically) label Feb 11, 2025
@LakshmiKalaKadali LakshmiKalaKadali added ready to pull ready to pull (create internal pr review and merge automatically) and removed ready to pull ready to pull (create internal pr review and merge automatically) labels Feb 25, 2025
@copybara-service copybara-service bot merged commit be8830f into master Mar 4, 2025
6 of 9 checks passed
copybara-service bot pushed a commit that referenced this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models:official models that come under official repository ready to pull ready to pull (create internal pr review and merge automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MixUp + Cutmix implementation is (badly!) incorrect

3 participants