DAFormer
DAFormer copied to clipboard
More detail about T-SNE visual
I try use T-sne to visual the features. But I meet some problems.
There are a total of 500 verified images on the citycapes dataset. I use the model to predict the image, keep the final output features, and upsample to the image label size. Then feature visualization. But I failed because the size is very large and the visualization failed or visualization didn't work out well like your papaers. So I'd like to ask you about details of your use of tsne. Do you save 500 images features for visual? I have tried many methods, but all fall.
here's my code
tsne_features = []
tsne_labels = []
for index, batch in enumerate(testloader):
images, labels, = batch
outputs = model(images).squeeze(0).permute(1,2,0).reshape(-1, 10) # it's feaures size is very big
tsne_features.append(outputs)
tsne_labels.append(labels.squeeze(0).reshape(-1))
features = np.concatenate(tsne_features, axix = 0)
labels = np.concatenate(tsne_labels, axix = 0)
from tsnecuda import TSNE
from sklearn.decomposition imort PCA
embeddings = TSNE(n_components = 2, perplexity=15, learning_rate = 10).fit_transform(features)
plt.figure(figsize=(10, 8))
scatter = plt.scatter(embedding[:0], embeddings[:,1], c= labels, camp="tab20", alph=0.6, edgecolors='w', linewidths=0.5)
plt.colobar(scatter)
plt.title("t-sne visual")
plt.show()