Skip to content
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

uniform_negative seed has no effect #2

Closed
vonGameTheory opened this issue Jun 10, 2020 · 7 comments
Closed

uniform_negative seed has no effect #2

vonGameTheory opened this issue Jun 10, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@vonGameTheory
Copy link

If using "uniform_negative", the random seed has no effect so you always get the same weights if the input length and nhid values are the same. Looks like this is because you are using Mersenne twister random engine for those and seed isn't affecting it. (Maybe just rescale uniform to -1,+1?)

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the bug Something isn't working label Jun 10, 2020
@mlampros
Copy link
Owner

mlampros commented Jun 10, 2020

@vonGameTheory thanks for making me aware of this issue. As suggested I adjusted the code to rescale the normal positive distribution to range [-1,1]. Let me know if it works for you too.
You can install the updated code using:

remotes::install_github('mlampros/elmNNRcpp')

@vonGameTheory
Copy link
Author

That fixes the seed issue, and in practice is probably fine, but now that I think about it your solution is not strictly quite correct -- you are rescaling the generated VALUES to -1,+1 which means you always get a weight of exactly -1 at the low end and always get a high weight also of +1. But we really want to rescale the RANGE, so if there is no library function that accepts a range argument (I'm not a C++ coder so I'm afraid I can only point out things without actually fixing them), we should instead take the generated values and do : (uniform_values * 2) -1 or something like that to rescale the range. (And the uniform positive values are between 0 and 1 so you never actually would get a full -1 or +1 weight just as you never get an actual 0 or +1 weight with positive.)

@mlampros
Copy link
Owner

@vonGameTheory thanks for make me aware of this. Based on the runif() function in R,

runif will not generate either of the extreme values unless max = min or max-min
 is small compared to min, and in particular not for the default arguments

Would you mind adding a minimal reproducible example based on your data (or random data) so that I have a starting point to fix this issue? thanks.

@vonGameTheory
Copy link
Author

vonGameTheory commented Jun 10, 2020

What I am saying is that in your updated code, for uniform_negative, you generate random weights in the range [0,1] (just like for uniform_positive) and then rescale those weights to -1,+1, which means you ALWAYS get a -1 and a +1 in your weights matrix.

e.g. if we generate the weights from the random function w = [0.2, 0.4, 0.1, .8] and then we rescale them rescale(w,min(w),max(w),-1,+1) we get [-0.71, -0.14, -1, +1]
^ that's what your code is doing now

Which like I said, is probably fine in practice as far as ELM performance since they are just random weights anyway. But still more correct would be to rescale the potential range of those weights instead of the specific weight vector, so we should rescale(w,0,1,-1,+1) (setting incoming range to min=0, max=1) instead and the result would then be [-0.6,-0.2,-0.8,+0.6] for that specific vector. A lazy way of doing that is just (w*2)-1

@mlampros
Copy link
Owner

@vonGameTheory thanks for your suggestions. I've updated the 'negative_uniform' function. Please let me know if it works for your too.

@vonGameTheory
Copy link
Author

Yep, looks good. Nice package! I just noticed I'm using one of your others too -- KernelKnn -- good stuff, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants