How can i calculate precision and recall in a Siamese network

5 vues (au cours des 30 derniers jours)
Nagwa megahed
Nagwa megahed le 23 Mar 2022
i need help,
my reseach is about building a siamese network like this example Train a Siamese Network to Compare Images
in the attached example the accurcy of the model is calculated by this code, i ask how i can calculate the precision and recall of that model
accuracy = zeros(1,5);
accuracyBatchSize = 150;
for i = 1:5
% Extract mini-batch of image pairs and pair labels
[X1,X2,pairLabelsAcc] = getSiameseBatch(imdsTest,accuracyBatchSize);
% Convert mini-batch of data to dlarray. Specify the dimension labels
% "SSCB" (spatial, spatial, channel, batch) for image data.
X1 = dlarray(X1,"SSCB");
X2 = dlarray(X2,"SSCB");
% If using a GPU, then convert data to gpuArray.
if (executionEnvironment == "auto" && canUseGPU) || executionEnvironment == "gpu"
X1 = gpuArray(X1);
X2 = gpuArray(X2);
end
% Evaluate predictions using trained network
Y = predictSiamese(net,fcParams,X1,X2);
% Convert predictions to binary 0 or 1
Y = gather(extractdata(Y));
Y = round(Y);
% Compute average accuracy for the minibatch
accuracy(i) = sum(Y == pairLabelsAcc)/accuracyBatchSize;
end

Réponses (1)

yanqi liu
yanqi liu le 24 Mar 2022
yes,sir,may be use model to test data output,and use
[tpr,fpr,thresholds] = roc(targets,outputs)
to get roc

Catégories

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

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by