output of neural network changes
3 views (last 30 days)
Show older comments
giacomo baccolo
on 20 Apr 2021
Answered: Shashank Gupta
on 26 Apr 2021
Hi everyone,
I have trained a LSTM neural network to classify some sequences. The sequence length is 50 and the number of classes is 4.
I tried the network to classify a new set of data for an external validation of the network perfomances.
I noticed that the classifications change depending on how I feed the network.
I tried two approach:
to feed the network with all the data in one time
to feed the network one sample at a time within a for loop
YPred_val1 = classify(net,X_valN);
for i = 1:size(X_valN,2)
YPred_val2(i) = classify(net,X_valN(:,i));
end
I thought the results would be identical (I expected YPred_val1 equal to YPred_val2) in the two tries but actually the classifications are different, about the 50% of the samples has a different predicted label comparing the results.
do you have any idea why? maybe I m missing something?
Many thanks
Giacomo
0 Comments
Accepted Answer
Shashank Gupta
on 26 Apr 2021
Hi,
It won't be necessarily identical, since you are dealing with LSTM network which means the testing data is sequencial in nature, so if each time step given as input to trained network will not be necessarily give same output as compared to giving all seqeunces at one time because of LSTM behaviour. The second approach which you tried will consider each time stamp as independent identity while the first approach where each time stamp is connected to previous timestamp. If its a general CNN network then sure both the result will be identical.
I hope my explaination make sense.
Cheers.
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!