Comments (7)
多谢你的关注!
这个is_pos
的第i
行表示所有样本和第i
个样本之间是否是同一个id,对角线上肯定是True
,如果第j
, k
, l
个样本和第i
个样本同一个id,那么第i
行的第j
, k
, l
应该是True
。is_pos
一般情况下不是对角阵。这个错误我没能一眼看出来是哪里的不兼容。
from alignedreid-re-production-pytorch.
N = dist_mat.size(0) #这是您N的定义
您之前定义了N的大小,为矩阵大小,
然而当队列中出现相同的ID的时候,即为非对角矩阵时,那么
is_pos = labels.expand(N, N).eq(labels.expand(N, N).t()) ,
dist_mat[is_pos]的维数就会不等于N。
那么,下面很多用N定义的就会报错了,比如下面这行:
dist_ap, relative_p_inds = torch.max(
dist_mat[is_pos_test].contiguous().view(N, -1), 1, keepdim=True)#报错
dist_mat[is_pos_test].contiguous()的维数不等于N,就不能用view(N,1).您看我理解的对吗,是不是我哪边理解错了。
from alignedreid-re-production-pytorch.
举个例子,labels
是[1, 2, 3, 4, 2, 1, 3, 4, 4, 2, 1, 3]
,也即4个id,每个id有3张图片,那么is_pos
应该是(为了简化,下面的1
表示True
, 0
表示False
):
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0
0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1
0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0
0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1
0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0
0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0
0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1
对角线都是1
,每一行总共有3个1
,所以dist_mat[is_pos].contiguous().view(N, -1)
里边的-1
就相当于3
,dist_mat[is_pos].contiguous().view(N, -1)
的结果是一个12*3
的数组。
我发现上面你的代码中好像有点问题,dist_ap, relative_p_inds = torch.max( dist_mat[is_pos_test].contiguous().view(N, -1), 1, keepdim=True)
这里边is_pos_test
不对吧,应该是is_pos
。
from alignedreid-re-production-pytorch.
后来发现是我对triplet loss的理解问题。哈哈,谢谢大佬。大佬在国外的吗?羡慕。
from alignedreid-re-production-pytorch.
大佬这个还是不敢当。。没在国外啊。。。
from alignedreid-re-production-pytorch.
后来发现是我对triplet loss的理解问题。哈哈,谢谢大佬。大佬在国外的吗?羡慕。
N = dist_mat.size(0) #这是您N的定义
您之前定义了N的大小,为矩阵大小,
然而当队列中出现相同的ID的时候,即为非对角矩阵时,那么
is_pos = labels.expand(N, N).eq(labels.expand(N, N).t()) ,
dist_mat[is_pos]的维数就会不等于N。
那么,下面很多用N定义的就会报错了,比如下面这行:
dist_ap, relative_p_inds = torch.max(
dist_mat[is_pos_test].contiguous().view(N, -1), 1, keepdim=True)#报错dist_mat[is_pos_test].contiguous()的维数不等于N,就不能用view(N,1).您看我理解的对吗,是不是我哪边理解错了。
我也遇到了这个问题,你解决了吗?
from alignedreid-re-production-pytorch.
举个例子,
labels
是[1, 2, 3, 4, 2, 1, 3, 4, 4, 2, 1, 3]
,也即4个id,每个id有3张图片,那么is_pos
应该是(为了简化,下面的1
表示True
,0
表示False
):1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1
对角线都是
1
,每一行总共有3个1
,所以dist_mat[is_pos].contiguous().view(N, -1)
里边的-1
就相当于3
,dist_mat[is_pos].contiguous().view(N, -1)
的结果是一个12*3
的数组。我发现上面你的代码中好像有点问题,
dist_ap, relative_p_inds = torch.max( dist_mat[is_pos_test].contiguous().view(N, -1), 1, keepdim=True)
这里边is_pos_test
不对吧,应该是is_pos
。
要是labels = [1, 2, 3, 4, 2, 1, 3, 4, 4, 2, 1, 1]这样的话,不就没法搞了吗
from alignedreid-re-production-pytorch.
Related Issues (20)
- top-k结果可视化 HOT 2
- CUHK03和DUKE上的识别率 HOT 1
- How to inference my own test set
- Keys not found in source state_dict HOT 1
- Global Feature Extraction HOT 1
- Local feature dimensions
- About performance on market1501 for global learning and mutual learning
- Is it generalised
- TypeError: __init__() got an unexpected keyword argument 'log_dir'
- AssertionError HOT 3
- 请问论文中的Resnet50-Xception结构是不是没有实现? HOT 1
- 论文复现的参数问题
- how to use the test data to draw picture just like roc missrate cmc?
- How to use without GPU? HOT 2
- could you send me a partitions.pkl about market1501 HOT 1
- 为啥用你提供的weight测得market也只有88.78的top1呢 HOT 1
- how to infer some images or videos
- RuntimeError: cannot perform reduction function min on tensor with no elements because the operation does not have an identity
- Poor performnace when reproducing evaluation on market1501 HOT 2
- would you help me to fix this error?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alignedreid-re-production-pytorch.