Add scale parameter to PowerNorm #30542
Open
+236
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Scale Parameter to PowerNorm init with default value 1.0 Apply scaling in call method before normalization Handle inverse scaling in inverse method
Add comprehensive text for scale parameter functionality Maintains backward Compatibility
PR summary
This PR adds a
scale
parameter to the PowerNorm class to allow pre-scaling of input data before applying power normalization.Why is this change necessary?
Users sometimes need to scale their data before applying power normalization, which currently requires manual preprocessing. Adding a built-in scale parameter makes this workflow more convenient and consistent.
What problem does it solve?
Provides a clean way to scale input data before normalization without requiring users to manually transform their data or create wrapper functions.
Implementation details:
scale
parameter toPowerNorm.__init__
with default value 1.0 (maintains backward compatibility)__call__
method to apply scaling before normalization:scaled_data = data * self.scale
inverse
method to handle reverse scaling:return result / self.scale
test_PowerNorm_scale
to verify functionalityExample usage: