MATLAB中的神经网络,初始权重

问题描述:

我用newff(...)在MATLAB中建立了神经网络.当您使用相同的输入和输出对其进行训练时,在不同的运行中训练结果会有所不同.我知道发生这种情况是因为每次运行时权重都不同.我的问题是,每次训练NN时如何使初始权重相同,以便获得相同的结果? 此外,是否有可能从训练No1中节省一些权重,然后再将其用于训练No2中?如何实现?

I made Neural Network in MATLAB with newff(...). When you train it with the same inputs and outputs, the training results are different on different runs. I understand that it is happening because the weights are different for each time I run it. My question is how to make initial weights to be the same each time I train my NN so I can get the same results? Also, is it possible to save some weights from training No1 and latter use it for training No2, and how?

Tnx

方式(取决于您所使用的MATLAB版本):

To generate reproducible results, you need to manually set the random number generator to the same seed/state at the beginning of the code. This can be done in a number of ways (depending on what version of MATLAB you have):

旧样式:

rand('twister',1234)

更新后的样式:

RandStream.setGlobalStream( RandStream('mt19937ar','Seed',1234) );

R2011a中引入了新功能,该功能简化了最后一个功能.致电:

A new function was introduced in R2011a that simplifies the last call:

rng(1234,'twister')

后一种语法是推荐的方法.

The latter syntax is the recommended approach.