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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!