How can i calculate precision and recall in a Siamese network

5 visualizaciones (últimos 30 días)
Nagwa megahed
Nagwa megahed el 23 de Mzo. de 2022
Respondida: yanqi liu el 24 de Mzo. de 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

Respuestas (1)

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

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by