-
Notifications
You must be signed in to change notification settings - Fork 24
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
handle min = max case during data normalization #208
Conversation
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.
Just left a small question to think about before merging!
@@ -11,6 +11,10 @@ class NeuralNetworkUtils { | |||
*/ | |||
// eslint-disable-next-line class-methods-use-this | |||
normalizeValue(value, min, max) { | |||
// When min is equal to max, set everything to 0 | |||
if (min === max) { | |||
return 0; |
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.
So just thinking about this a bit, should we log some sort of warning in the console? Perhaps we should also just return min
(or max
) to keep the original values? And log that they cannot be normalized?
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.
I think a warning would be helpful! I am not sure how to word it though. Perhaps "The input parameter cannot be normalized because all values for that parameter are identical. The NeuralNetwork can still be trained, but please check your input data".
If we keep the original (non-zero) data, that parameter effectively becomes a bias value for the next layer since it is constant. If we zero that parameter we are pretty much deleting it from the neural network. I'm not sure whether keeping it could throw off the training, but I'm leaning toward just zeroing the parameter since it doesn't contribute to training anyway.
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.
Ah, I see what you mean! How about:
console.warn("Normalization failed: All values for this feature are identical (min === max). The data for this feature will be set to 0, effectively removing it from the model. Please check your input data.");
What do you think?
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.
Sounds good! I will work on this.
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.
Great! let me know when it is ready to merge! Maybe we can do a release after this one?
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.
Ready to merge!
Yay, great work @ziyuan-linn! |
This PR addresses issue #204 by adding a check for
min === max
innormalizeValue
, preventing the divide by zero situation.