How can i calculate precision and recall in a Siamese network

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

回答(1 个)

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

类别

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

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by