output of neural network changes

3 次查看(过去 30 天)
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

采纳的回答

Shashank Gupta
Shashank Gupta 2021-4-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by