Search code examples
matlabparallel-processingneural-networkrandommersenne-twister

Why there isn't any sub-stream capability of mersenne twister random number generator in MATLAB and how we can solve it?


I'm using parallel computing and i need different sub-streams (independent sub-stream) of random numbers in every worker (logical core) in MATLAB. When i set sub-streams to mlfg6331_64 or mrg32k3a My performance with neural network in parfor loop is so low but when i generate random weights outside of parfor by rnf - mersenne twister my performance is higher.

  • Why MATLAB doesn't support mersenne twister as sub streams? My MATLAB version is R2014a. Is any support of this feature in R2014b?

  • How can i create independent streams of random numbers using mersenne twister before parfor and insert (for instance weights of neural network) to parfor loops? (for example using a loop before parfor loop)


Solution

  • It's not that MATLAB doesn't support substreams with Mersenne twister, it's that Mersenne twister doesn't support substreams.

    If the choice of RNG is affecting the performance of your NN, something bigger is going wrong.