How can I get Same Results form multiple networks with same network architecture, network options and training and validation data ?

4 visualizzazioni (ultimi 30 giorni)
Hi everyone
I want to train the best neural network for my data. for this porpose I compared many parameter that affect the network, for example : number of layers. but for constant layer, every time I run the code, resluts (RMSE and ...) are not same. I guess this problem related to randomness of training, such as Shuffle in training option or initializing of weights ans biases. I set Training ans Validation data manually with out any changing and added this commands to my code :
option = trainingOptions('Shuffle','never');
but it didn't give same RMSE. what should I do ?
best regards

Risposte (1)

Ayush Aniket
Ayush Aniket il 9 Mag 2025
Even if you set Shuffle, never in trainingOptions, the results can vary between runs unless you control all sources of randomness. You should ensure to follow all the below steps:
1. Use rng to set the random number generator seed before training. This ensures that weight initialization and any other random operations are repeatable. Refer to the following documentation link to read about the function: https://www.mathworks.com/help/matlab/ref/rng.html
rng(0); % You can use any fixed integer
2. You have already set Shuffle, never in trainingOptions, which prevents data order from changing.
3. Finally, make sure your training and validation datasets are exactly the same for each run.

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by