nodevectors icon indicating copy to clipboard operation
nodevectors copied to clipboard

defining random state or seed option parameters

Open kahramankostas opened this issue 4 years ago • 3 comments

I need the option to assign random state or seed values to get stable results. I don't think there is such an option. Unfortunately, my attempts to fix the general seed that I have listed below did not solve the problem.

import random
random.seed(1)
from numpy.random import seed
seed(1)

What can be done about it? Do you have any advice? thanks in advance

kahramankostas avatar Nov 21 '21 13:11 kahramankostas

Thanks.

Are you looking at node2vec specifically? I agree that all the algorithms should support it, however. For Node2vec we'd have to manually seed for the random walks, and once again on when training the network. I don't think it would be too much work to do.

VHRanger avatar Nov 21 '21 15:11 VHRanger

Seems like the seeding has to be wrapped by numba jit code, see this issue: https://github.com/numba/numba/issues/6002

(Random walks are numba-jitted)

The long term fix will be in the CSRGraphs package as well

VHRanger avatar Nov 24 '21 13:11 VHRanger

Having looked deeper into it, this is more complex than it seems - we use numba.prange in loops for threading, so setting a numba seed before the multithreaded loop doesn't guarantee replicable results.

It's seemingly unresolved on the numba side; see this issue:

https://github.com/numba/numba/issues/4452

VHRanger avatar Nov 28 '21 13:11 VHRanger