-
Notifications
You must be signed in to change notification settings - Fork 45.5k
Updated parse_policy_info
function in augment.py
#13509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This PR is raised to add more flexible control over the randomness in the augmentation process by changing `level += tf.random.normal([], dtype=tf.float32)` to `level += level_std * tf.random.normal([], dtype=tf.float32)` to the function `parse_policy_info` instead of standard deviation always 1.
@@ -1869,7 +1869,7 @@ def _parse_policy_info(name: str, | |||
func = NAME_TO_FUNC[name] | |||
|
|||
if level_std > 0: | |||
level += tf.random.normal([], dtype=tf.float32) | |||
level += level_std*tf.random.normal([], dtype=tf.float32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will change the behavior completely. I am worrying about the effects of this. Have you done any tests verifying it won't break existing results using this augmentation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK to bring more flexibility, but the default behavior should keep backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I'm a grad student working on a research project about using large language models to automate code review. Based on your commit 06cbb37 and the changes in official/vision/ops/augment.py, my tool generated this comment:
- Null Value Checks: The function
_parse_policy_info
does not check if the parameters areNone
before using them. It is advisable to add checks at the beginning of the function to ensure that these parameters are valid. - Data Type and Range Validation: Ensure that
level_std
is validated before it is used in the multiplication. Iflevel_std
is negative or not a number, it could lead to unexpected behavior. Consider adding checks to ensure thatlevel_std
is a non-negative float. - Type Checks: There are no checks to ensure that the types of the parameters are as expected. For instance,
replace_value
should be a list of integers, andlevel_std
should be a float. - Clipping of Level: Verify that the new value of
level
after scaling does not exceed_MAX_LEVEL
or fall below 0, especially iflevel_std
is large. - Handling Abnormal Page Data: The code does not handle cases where
level
might exceed_MAX_LEVEL
after the addition of noise. It is important to ensure that the input totf.clip_by_value
is valid. - Functionality of
level_to_arg
: Ensure that the functions mapped inargs
can handle the new range oflevel
values correctly. If any of these functions expectlevel
to be within a specific range, the scaling could lead to errors or unexpected behavior. - Function Argument Validation: The function
level_to_arg
returns a dictionary of functions based on thename
parameter. There should be a check to ensure thatname
is valid and exists in theargs
dictionary. - Scaling of Random Normal Value: Ensure that
level_std
is intended to be a scaling factor for the randomness; otherwise, this could introduce unintended behavior. - Error Handling: Consider implementing error handling for cases where the random generation or subsequent calculations fail. This can prevent the application from crashing or behaving unpredictably.
- Testing: Implement unit tests that cover various scenarios, including edge cases where
level_std
is 0, very small, or very large, to ensure that the changes do not introduce any logical errors in the overall functionality. - Testing for Variability: Add tests to verify the variability of
level
whenlevel_std
is set to different values (e.g., 0, positive values). Ensure that the outputlevel
reflects the expected range based on the inputlevel_std
. - Boundary Tests: Add tests to check the behavior of the
level
variable whenlevel_std
is set to 0. The output should equal the inputlevel
.
As part of my research, I'm trying to understand how useful these comments are in real-world development. If you have a moment, I'd be super grateful if you could quickly reply to these two yes/no questions:
-
Does this comment provide suggestions from a dimension you hadn’t considered?
-
Do you find this comment helpful?
Thanks a lot for your time and feedback! And sorry again if this message is a bother.
This PR is raised to add more flexible control over the randomness in the augmentation process by changing
level += tf.random.normal([], dtype=tf.float32)
tolevel += level_std * tf.random.normal([], dtype=tf.float32)
to the functionparse_policy_info
instead of standard deviation always 1.