日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

lfw数据验证

發(fā)布時(shí)間:2023/12/20 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lfw数据验证 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

LFW數(shù)據(jù)驗(yàn)證

以facenet的lfw數(shù)據(jù)驗(yàn)證為例 lfw數(shù)據(jù)地址:
http://vis-www.cs.umass.edu/lfw/ lfw數(shù)據(jù):
  • 13233 images
  • 5749 people
  • 1680 people with two or more images

驗(yàn)證數(shù)據(jù)分兩個(gè),一個(gè)用于開發(fā),一個(gè)用于最終的驗(yàn)證
這里驗(yàn)證使用的是View 2的pairs.txt文件

training, validation, and testing
? ?View 1: development training/testing sets
? ?View 2: performance testing configurations
? ?pairs.txt file format
? ?people.txt file format

pairs.txt 包含了按10交叉驗(yàn)證隨機(jī)分布的測(cè)試人臉對(duì)

1.mean classification accuracy

def calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10):assert(embeddings1.shape[0] == embeddings2.shape[0])assert(embeddings1.shape[1] == embeddings2.shape[1])nrof_pairs = min(len(actual_issame), embeddings1.shape[0])nrof_thresholds = len(thresholds)k_fold = KFold(n_splits=nrof_folds, shuffle=False)tprs = np.zeros((nrof_folds,nrof_thresholds))fprs = np.zeros((nrof_folds,nrof_thresholds))accuracy = np.zeros((nrof_folds))diff = np.subtract(embeddings1, embeddings2)dist = np.sum(np.square(diff),1)indices = np.arange(nrof_pairs)for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)):# Find the best threshold for the foldacc_train = np.zeros((nrof_thresholds))for threshold_idx, threshold in enumerate(thresholds):_, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set])best_threshold_index = np.argmax(acc_train)for threshold_idx, threshold in enumerate(thresholds):tprs[fold_idx,threshold_idx], fprs[fold_idx,threshold_idx], _ = calculate_accuracy(threshold, dist[test_set], actual_issame[test_set])_, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], actual_issame[test_set])tpr = np.mean(tprs,0)fpr = np.mean(fprs,0)return tpr, fpr, accuracy

def calculate_accuracy(threshold, dist, actual_issame):predict_issame = np.less(dist, threshold)tp = np.sum(np.logical_and(predict_issame, actual_issame))fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame)))fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame))tpr = 0 if (tp+fn==0) else float(tp) / float(tp+fn)fpr = 0 if (fp+tn==0) else float(fp) / float(fp+tn)acc = float(tp+tn)/dist.sizereturn tpr, fpr, acc

這里的accuracy是使用pairs.txt中的人臉對(duì)進(jìn)行10交叉驗(yàn)證得到的平均準(zhǔn)確率

2.roc

thresholds = np.arange(0, 4, 0.01) tpr和fpr分別對(duì)應(yīng)交叉驗(yàn)證的平均tpr和平均fpr

總結(jié)

以上是生活随笔為你收集整理的lfw数据验证的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。