Why didnt get the same result even when using RNG function?

1 view (last 30 days)
Hello everyone,
I utilized the RNG (Random Number Generator) function to ensure result reproducibility when employing the entire matrix in CNN . However, upon selecting just two columns of the matrix and rerunning the code several times, I did not obtain the same result consistently. With the entire matrix, I consistently achieved the same result. Ps: I am using parallel environment.
rng(0);
appp=mfcc_matrix_app;
testt=mfcc_matrix_test;
% CNN code
%always get the same result
However, when I select just two columns and rerun the code several times, I didn't get the same result.
rng(1);
t=[1,2];
for j =1:length(t)
appp = mfcc_matrix_app(:, t(1:end)) ;
testt = mfcc_matrix_test(:, t(1:end)) ;
% CNN code
%didnt get the same accuracy
end
would anyone help me please! thanks in advance.

Answers (1)

Steven Lord
Steven Lord on 16 Nov 2023
Suppose you stack a deck of cards in a particular way. You then play a hand of standard five-card draw poker with 3 players. You deal out 5 cards to each player, meaning that the first card to be dealt during the draw phase is the 16th in the deck.
Then you stack the deck the exact same way to play the next hand, but one of the players steps away from the table to take a phone call. You deal out 5 cards to each player, meaning that the first card to be dealt during the draw phase is the 11th in the deck.
The results of the two hands won't be identical even though the deck was in the same state before each hand.
What guarantee do you have that the CNN code generates the exact same quantity of random numbers in each case, if the number of random numbers it requires is based on how much data you have?
  2 Comments
Hamza
Hamza on 16 Nov 2023
@Steven Lord Thank a lot for your response. I agree with your point. However, what I didnt understand is that while I achieved 85% accuracy consistently using the entire matrix with rng(0), upon selecting only one column with rng(1) and running it multiple times, I obtained varying results. This outcome seems illogical as it should ideally remain constant, similar to the performance of the entire matrix.

Sign in to comment.

Categories

Find more on Recognition, Object Detection, and Semantic Segmentation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!