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

use seeded randomness #335

Open
wighawag opened this issue Sep 28, 2018 · 6 comments
Open

use seeded randomness #335

wighawag opened this issue Sep 28, 2018 · 6 comments

Comments

@wighawag
Copy link

Currently synaptic use Math.random inside the code like
https://github.com/cazala/synaptic/blob/master/src/Neuron.js#L60

This means when you create a neural network, it will behave differently when run in different computers / different times

It would be a good idea to (maybe optionally) specify a seed that get used for all randomness execution.

Currently I can just monkey-patch Math.random for that but this is not ideal.

@ghost
Copy link

ghost commented Oct 3, 2018

Yes, but a fine tuned NN will perform very similar on each run. Also, if you want to increase the prediction score you want to run a swarm of NNs (at least 8) and median their output. So different results are actually a good thing.

@wighawag
Copy link
Author

wighawag commented Oct 3, 2018

For my use case (a game) I need reproducible output.

Note for those who want randomness for the swarm use case you mention for example, different seeds can be given. The point here is that if the library do not allow to set a seed (could be optional as mentioned), the only way to have reproducible output is to monkey patch Math.random

@flesler
Copy link

flesler commented Oct 27, 2018

+1, determinism is a plus and I see no downside

@SNavleen
Copy link

SNavleen commented Nov 12, 2018

Hi,

I just came across this, and it wouldn't hurt to have seeded randomness.

If you would like I can work on this and create a pull request. I have previously used seedrandom, in my sample neural network library. There is a np version of this library as well if needed.

If some one can assign me this task please let me know.

Thanks

@flesler
Copy link

flesler commented Nov 12, 2018

I would say that just adding something like a synaptic.random() that returns Math.random() and using it everywhere, will let "us" override it any way we want. That seems simpler and overall preferable, each can decide which random implementation to override with, when to reset it, etc

@SNavleen
Copy link

That would be much better. I will retract my statement saying I can work on it since I am not sure how I would go about implanting it. I might still give it a try, to help me learn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants