Reproducibility in neural network
Mostrar comentarios más antiguos
I'm trying to breakdown the MATLAB neural network GUI by working out what each feature does. I'm keeping it simple by using the default training method (scg), and the MATLAB wine dataset for training/testing. For the time being, and for experimentation, I've removed the validation dataset, and I've set the NN up with 50 hidden nodes.
What I can't work out is why the results it produces are exactly the same each time. It takes exactly the same amount of epochs to get to the minimum gradient, performance and gradient values are exactly the same, and the results produced in the confusion matrix are exactly the same. The only thing I can think of is that the data splitting and initialisation of weights are not randomised, but everywhere I look online suggests that (by default) MATLAB does indeed randomise those parameters.
What am I missing? Are the weights and datasets not randomised after all? Code being used is below.
% Load MATLAB default wine dataset.
[x1,t1] = wine_dataset;
% Create net, 50 hidden nodes.
net = patternnet(50);
% Split the data into a 75% training and 25% testing group. Validation
% removed.
net.divideParam.trainRatio = 3/4;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 1/4;
% Train the data.
train(net,x1,t1);
Respuesta aceptada
Más respuestas (1)
Star Strider
el 8 de En. de 2016
0 votos
‘The only thing I can think of is that the data splitting and initialisation of weights are not randomised, but everywhere I look online suggests that (by default) MATLAB does indeed randomise those parameters.’
You likely solved this yourself. I couldn’t find it in the current documentation (and I opted not to hack the GUI), but it is possible to set the random number generator using the rng function so that the seed (and the subsequent outputs) are always the same. MATLAB does this frequently in its documentation sample code to force results that are the same as the demonstration code.
2 comentarios
Richard
el 8 de En. de 2016
Star Strider
el 8 de En. de 2016
I haven’t used the Neural Network Toolbox in a while, but it could be that the data are sufficiently well characterised that every net of similar architecture would produce the same results, regardless of the random number generator seed. You would probably have to test the data with a different classifier (perhaps a k-th nearest neighbor classifier) to see if that is the situation.
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!