Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: rng(0) error in Neural Network
Posted:
Mar 6, 2013 5:02 PM


Lin, the error message in its entirety say this:
"The current random number generator is the legacy generator. This is because you have executed a command such as rand('state',0), which activates MATLAB's legacy random number behavior. You may not use RNG to reseed the legacy random number generator.
Use rng('default') to reinitialize the random number generator to its startup configuration, or call RNG using a specific generator type, such as rng(seed,'twister')."
So here's what happened: some time between when you started up MATLAB and when you tried to use the rng function, either you, some of your code, or some code you ran executed a command such as
rand('state',0)
or
randn('seed',0)
which has the effect of resetting MATLAB's random number generators to their old preR2008 configuration and behaviors. The rng function refuses to reseed the "legacy" generators.
That command is _strongly_ not recommended, and has been for a number of years. If you typed something like that at the command line, or put a line like that in a function or a script that you wrote, you should replace it as described here
http://www.mathworks.com/help/matlab/math/updatingyourrandomnumbergeneratorsyntax.html
which you can also find if you look at the reference page for the rng function
http://www.mathworks.com/help/matlab/ref/rng.html
If you can't figure out where that command is being executed, it may be that you've downloaded code for MATLAB Central that is doing it.
Hope this helps.
On 3/5/2013 4:24 PM, Lin wrote: > Hi! > I am using Matlab2011b version. In order for the Ntrials, to find the R2 > values for train/val/test, i used rng(0) before my fitnet(H). I have the > following error: > ???Error Using>>rng at 97 > The current random number generator is the legacy generator. This is > because you have executed a command such as > rand('state',0), which activates MATLAB..................... > > Anybody's help!



