## To do list

• 初步了解和STL algorithm有点像的基础算法库thrus突然GPU编程。。。cs179
• levelDB笔记，以及protobuff笔记
• cuda编程相关
• tensorRT
• 补工程知识
• 阅读caffe代码（重要）
• 补C++(cpp11)知识

## levelDB 学习笔记

### levelDB简介

1. 首先，LevelDb是一个持久化存储的KV系统，和Redis这种内存型的KV系统不同，LevelDb不会像Redis一样狂吃内存，而是将大部分数据存储到磁盘上。
2. 其次，LevleDb在存储数据时，是根据记录的key值有序存储的，就是说相邻的key值在存储文件中是依次顺序存储的，而应用可以自定义key大小比较函数，LevleDb会按照用户定义的比较函数依序存储这些记录。
3. 再次，像大多数KV系统一样，LevelDb的操作接口很简单，基本操作包括写记录，读记录以及删除记录。也支持针对多条操作的原子批量操作。
4. 另外，LevelDb支持数据快照(snapshot)功能，使得读取操作不受写操作影响，可以在读操作过程中始终看到一致的数据。
5. 除此外，LevelDb还支持数据压缩等操作，这对于减小存储空间以及增快IO效率都有直接的帮助。
6. LevelDb性能非常突出，官方网站报道其随机写性能达到40万条记录每秒，而随机读性能达到6万条记录每秒。总体来说，LevelDb的写操作要大大快于读操作，而顺序读写操作则大大快于随机读写操作。

### LevelDB的安装

leveldb_github地址

g++ mytest.cc -o mytest -lpthread -lleveldb

## caffe2 添加自定义op

c之后我们仿照caffe2/operators/accumultate_op.h和affe2/operators/accumultate_op.cc,仿写一个我们自己的运算atest_op.h和atest_op.cc

• D1:使用ilivids 数据集
• D1V1表示最初始的　baseline model
• D1V2表示改为使用一个fc
• D1V2_a是一个在一个FC上，不添加光流的修改版本
• D1V2_b是在一个FC上的baseline版本（也就是有光流）
• D1V2_c是在一个FC上，有光流，batchsize从３２改为６４，gpu数目从4改为8的版本
• D1V3表示将softmax改为sigmod
• D1V3_b表示将softmax改为sigmod的baseline版本
• D2:使用prid2011数据集
• D2V1表示初始的baseline model
• D2V2表示改为使用一个fc
• D2V2_b是在一个FC上的baseline版本

## 分类评价指标之Cumulative Match Characteristi (CMC)曲线

CMC曲线全称是Cumulative Match Characteristic (CMC) curve，也就是累积匹配曲线，同ROC曲线Receiver Operating Characteristic (ROC) curve一样，是模式识别系统，如人脸，指纹，虹膜等的重要评价指标，尤其是在生物特征识别系统中，一般同ROC曲线（ 多标签图像分类任务的评价方法-mean average precision(mAP) 以及top x的评价方法）一起给出，能够综合评价出算法的好坏。

Shortly speaking, imagine that you have 5 classes. For simplicity, imagine you have one test per class. Each test produces a score when compared to each class. Let’s start from test1 which belongs to class1:
As your similarity measure, here, is Euclidian distance, the more distance a test has compared to a class, the less similarity is obtained. Without loss of generality, let’s suppose that the distance measures are calibrated and normalized in terms of similarity scores.
If the score between test1 and class1 is larger than the other 4 classes (or the Euclidian distance between test1 and class1 is less than the other 4 classes), class 1 is recognized in the first rank. As an example, let’s suppose the following similarity scores (not Euclidian distances):
Test1 VS class 1= .95
Test1 VS class 2= .7
Test1 VS class 3= .9
Test1 VS class 4= .72
Test1 VS class 5= .3
What do these scores say? These similarity scores say that test 1 is more similar to class 1 than the other classes. So, test 1 is correctly recognized in the first rank.
Let’s suppose that test2, test 3, test 4 and test 5 are also recognized in the first rank.
So, we can conclude that we have a perfect CMC curve (y-x). because all of the 5 test are correctly recognized. A perfect CMC curve is as following:
Rank 1: 100%
Rank2: 100%
Rank 5:100%
Now, let’s suppose the following situation:
Test1 VS class 1= .9
Test1 VS class 2= .95
Test1 VS class 3= .4
Test1 VS class 4= .72
Test1 VS class 5= .3
What do these scores say? They say that test 1 is more similar to class 2 than class 1 (This is a mismatch and it is not correct!). So, the correct match (.9) is not the top match here (the top match is .95 which is a mismatch). In other words, test 1 is not recognized as the top match, but it is recognized among top “two matches” (the top two matches are .95 and .9). This is what rank 2 recognition means!
Now, if test 1 is recognized among top two matches but the other tests (i.e., test 2, test 3,… test 5) are recognized in the first rank (Rank 1), the first rank recognition rate is 80% (test 1 is not among the top matches, i,e, 1 out of 5 is incorrect in first rank recognition which yields 80%) but the second rank recognition rate is 100%, because all of the tests are correctly recognized among the top “two matches”. Some of them are recognized in the first rank (test 2, test 3, test 4, and test 5) while some of them are recognized in the second rank (test 1). So, the second rank recognition rate is 100%.
So, the CMC curve will be as following:
Rank1  80% (tests 2,3,4,5 are among the N=1 top matches )
Rank2 100% (tests 1,2,3,4,5 are among the N=2 top matches )
Rank3 100%  (tests 1,2,3,4,5 are among the N=3 top matches )
Rank 5 100%  (tests 1,2,3,4,5 are among the N=5 top matches )
Now, consider that test1, test 2, test 3 are recognized in the first rank, test 4 is recognized in the second rank and test 5 is recognized in the fourth rank. what is the CMC curve>? Here is the answer:
Rank 1:  60% (tests 1,2,3 are among the N=1 top matches )
Rank 2: 80% (test 1,2 ,3 ,4 are among N=2 top matches)
Rank 3: 80% (test 1,2 ,3 ,4 are among N=3 top matches)
Rank 4: 100% (test 1,2 ,3 ,4 and 5 are among N=4 top matches)
Rank 5: 100% (test 1,2 ,3 ,4 and 5 are among N=5 top matches)
Reference:
Grother, Patrick, Ross J. Micheals, and P. Jonathon Phillips. “Face recognition vendor test 2002 performance metrics.” Audio-and Video-Based Biometric Person Authentication. Springer Berlin Heidelberg, 2003.

## Reid iLIDS-VID 数据集 切分

ilids-vid数据集

150个人做trainning,150个人做

## Pose-driven Deep Convolutional Model for Person Re-identification 阅读笔记

1709.08325

Reid问题指的是判断一个probe person 是否在被不同的camera捕获的gallery person 中出现。

ReID问题至今没有很好得解决，主要原因是，不同camera下，人的姿势（pose),观察的视角(viewpoint) 变化太大了。

1. 用一些在图像上抽取的不变量来作为人的特征feture
2. 去学习一个不同的距离度量方式，以至于同一个人在不同camera之间的距离尽可能小。

• 使用softmax loss 结合person ID labels得到一个global representation
• 首先用预定义好的body 刚体模型去得到local representation,然后将global 和local representation 融合。

• 提出了一种新的深层结构，将身体部分转化成相应的特征表示，以此来克服pose变化带来的问题
• 提出了一个用来自动学习各部分权值的sub-network