WentaoTan / Interleaved-Learning

Code for Style Interleaved Learning for Generalizable Person Re-identification (TMM 2023)
4 stars 0 forks source link

How to generate keshihua.mat for t-SNE visiualization? #3

Closed BJTUJia closed 6 months ago

BJTUJia commented 1 year ago

Hi there, thanks for this great work! One problem though, when I tried to use the tsne_1.py, there needs to generate a .mat for storing the features and labels. Can you give me some guidance on how to get the mat file? Thanks a lot in advance!

WentaoTan commented 1 year ago

Thank you very much! In tsne_1.py, we can see sentences like this:

result = scipy.io.loadmat('file.mat') feature = torch.FloatTensor(result['feature'])

What matters is how the feature came to be. Here, we save it as a.mat file for easy retrieval (rather than having to extract the RGB image into a tensor from start). The file saves the features you want to visualize; for example, if you have N photos, you may need to save a feature matrix with dimensions of N*2048.

Label is used to indicate which of the N features are domain0 and which are domain1 or domain2. For example, if the first 100 features are from domain 0 ( feature[:100,:] is from the same domain) , the code can be rewrote as:

a_1 = label == 0 plt.scatter(X_tsne[a_1, 0], X_tsne[a_1, 1], c='blue')

is equivalent to plt.scatter(X_tsne[:100, 0], X_tsne[:100, 1], c='blue')