MATLAB neural network classification different results

2 vues (au cours des 30 derniers jours)
Gediminas
Gediminas le 24 Mai 2014
Réponse apportée : Hamza le 23 Oct 2023
Hello,
i used MATLAB function "patternet" to create 1 layer (10 neurons) neural network classifier to classify data into 3 classes with default attributes (training function, initializatio and ect.). Suppose have matrix - NxM with rows corresponding to observations and columns are classification features. I found that when i use different combination of same features i get different classification results. For example, using matrix(:,[1 2 3]) gives different classification results (and also different weight values of whole network) compared with matrix(:,[1 3 2]).
Can somebody explain why it is so? Is this drawback is fundamentally related to neural networks classification algorithm or some implementation features?
  1 commentaire
Gediminas
Gediminas le 24 Mai 2014
Forgot to mention that when i use the same matrix several times with "patternet" (e.g. matrix(:,[1 2 3])) i get identical weight and classification values.

Connectez-vous pour commenter.

Réponse acceptée

Greg Heath
Greg Heath le 26 Mai 2014
When making multiple designs in a loop, use rng to initialize the random number generator BEFORE the loop. If the training function uses batch learning, the results will be independent of the order of the columns.
  3 commentaires
Image Analyst
Image Analyst le 26 Mai 2014
Gediminas's "Answer" moved to here:
I found that the problem is related to initialization of neural network weights. It gives the identical results every time i use same column configuration, but if i use rng('shuffle') each time i train and test network it gives different results even with the same column configuration. So the problem to me is now how to initialize randomly all weights without previous repetition without each time calling rng('shuffle')?
Greg Heath
Greg Heath le 25 Avr 2015
When training in a loop only initialize the RNG once: just before the outer loop

Connectez-vous pour commenter.

Plus de réponses (2)

Greg Heath
Greg Heath le 1 Juin 2014
Remember that the state of the RNG changes every time it is called. Now,
1. Net creation is different for the obsolete functions newfit and newpr which call newff than the corresponding new functions fitnet and patternnet which call feedforwardnet.
2. Obsolete
a. Random weight initialization occurs at net creation
b. Random data division occurs at the beginning of training
3. Current
a. Weights are no longer assigned at creation
b. Weights can be assigned before training using configure
. c. Random data division occurs at the beginning of training
d. Train will only assign initial weights to a weightless net
Therefore, if you are training multiple nets of the current version in a loop, you have to use configure to initialize weights at the beginning of the loop.
Hope this helps
Greg

Hamza
Hamza le 23 Oct 2023
Hello everyone, I'm facing the same issue on CNN. When I shuffled the features, I obtained different accuracy values, which ideally should remain consistent. Do you have any suggestions on how to resolve this issue? I am using Malba 2023.

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by