Comments (8)
You can use the code below to visualize the features.
def plot_embedding(data, label, title,show=None):
# param data:data
# param label:label
# param title:title of output
# param show:(int) if you have too much proposals to draw, you can draw part of them
# return: tsne-image
if show is not None:
temp = [i for i in range(len(data))]
random.shuffle(temp)
data = data[temp]
data = data[:show]
label = torch.tensor(label)[temp]
label = label[:show]
label.numpy().tolist()
x_min, x_max = np.min(data, 0), np.max(data, 0)
data = (data - x_min) / (x_max - x_min) # norm data
fig = plt.figure()
# go through all the samples
data = data.tolist()
label = label.squeeze().tolist()
for i in range(len(data)):
plt.text(data[i][0], data[i][1], ".",fontsize=18, color=plt.cm.tab20(label[i] / 20))
plt.title(title, fontsize=14)
return fig
# weight:(n proposals * 1024-D) input of the classifier
# label: the label of the proposals/ground truth
# we only select foreground proposals to visualize
# you can try to visualize the weight of different classes by extracting weight during training or testing stage
ts = TSNE(n_components=2,init='pca', random_state=0)
weight = ts.fit_transform(weight)
fig = plot_embedding(weight, label, 't-SNE feature child')
plt.show()
from fsce.
(1) Weight is the feature extract from the input of the classifier (1024-dimension). (I think it should be named feature)
(2) Weight and label are torch.tensor(), if you use another type, remember to convert them.
(3) TSNE is imported from sklearn.manifold, and here is the guild. https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html. Moreover, perplexity may need to be changed to get a better result.
from fsce.
(1) Weight is the feature extract from the input of the classifier (1024-dimension). (I think it should be named feature)
(2) Weight and label are torch.tensor(), if you use another type, remember to convert them.
(3) TSNE is imported from sklearn.manifold, and here is the guild. https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html. Moreover, perplexity may need to be changed to get a better result.
Are the perplexitys same for features learned with CPEloss and without CPEloss ?
from fsce.
(1) Weight is the feature extract from the input of the classifier (1024-dimension). (I think it should be named feature)
(2) Weight and label are torch.tensor(), if you use another type, remember to convert them.
(3) TSNE is imported from sklearn.manifold, and here is the guild. https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html. Moreover, perplexity may need to be changed to get a better result.Are the perplexitys same for features learned with CPEloss and without CPEloss ?
Yes.
We set perplexity=30, which is the default number recommended by the guild. You can just ignore this parameter.
from fsce.
(1) Weight is the feature extract from the input of the classifier (1024-dimension). (I think it should be named feature)
(2) Weight and label are torch.tensor(), if you use another type, remember to convert them.
(3) TSNE is imported from sklearn.manifold, and here is the guild. https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html. Moreover, perplexity may need to be changed to get a better result.Are the perplexitys same for features learned with CPEloss and without CPEloss ?
Yes
Got it. Thanks a lot!
from fsce.
hello, where should this code be added?
from fsce.
@chengyu0910
Please ask you a question, I will not have the true value label when I test the model, so how do I pass the label parameter when I draw T-SNE?
from fsce.
@chengyu0910 Please ask you a question, I will not have the true value label when I test the model, so how do I pass the label parameter when I draw T-SNE?
You can use the labels predicted by the model, as the model's predictions are relatively confident in test stage.
Or you can extract features and draw the T-SNE figure during training, where the sample's true label can be determined by the iou-matching with the ground truth bounding box annotations.
from fsce.
Related Issues (20)
- Is there a requirements document here? HOT 3
- 结果是否为多次实验取平均
- GPU: 3090, I can't install cuda10 0, how can I compile it? HOT 2
- prepare dataset error HOT 6
- python setup.py build develop HOT 13
- 1 shot and 2 shot do not use contrastive loss?
- I can not get the same results in split 1 and shot 10? I just have one gpu 3090. HOT 4
- Train on myself dataset
- AssertionError: Box regression deltas become infinite or NaN! HOT 2
- --opts KeyError: 'Non-existent config key: MODEL.WETGHTS'
- Hello~Where should this code be added?
- I have not found where requirements.txt is.
- I only have a V100 32G ,could realize this model?
- How long does the training step take?
- Where is the requirements.txt? HOT 1
- 我想知道fine tune的时候terminal会显示cl loss的变化吗(I want to know if the terminal will display the change of cl loss during fine-tuning)
- 我想知道fine tune的时候terminal会显示cl loss的变化吗(I want to know if the terminal will display the change of cl loss during fine-tuning)
- question about contrastive loss HOT 1
- do we need to change the max_iter according to the number of the shots?
- pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI HOT 1
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 fsce.