mxl1990 / tsne-pytorch Goto Github PK
View Code? Open in Web Editor NEWPytorch implementation for t-SNE with cuda to accelerate
License: MIT License
Pytorch implementation for t-SNE with cuda to accelerate
License: MIT License
Hello, my test code is as follow:
X1 = torch.randn([10, 2048]).cuda()
X_emb = TorchTSNE(n_components=2, perplexity=100., n_iter=1000).fit_transform(X1)
Sometimes, it will occur '{IndexError}index 2048 is out of bounds for dimension 1 with size 2048', I find the reason is that as 121 line in the tsne_pytorch.py
, there may be out of bounds:
119 for i in range(d):
120 if l[i, 1] != 0:
121 M[:, i+1] = M[:, i]
122 i += 1
Concretely, i
may equal to d-1 in 121 line which causes M[:,i+1] will be out of bounds(we know M is dxd).
I wonder if the modified code as follow is right?
for i in range(d-1):
if l[i, 1] != 0:
M[:, i+1] = M[:, i]
i += 1
Thank you for sharing the code. Is max_iter = 1000 fixed, or set it according to own data set?
Here is an example:
from tsne_torch import TorchTSNE as TSNE
# from sklearn.manifold import TSNE
import torch
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
dataset = torchvision.datasets.MNIST(root="path of the dataset",
train=False,
download=False,
transform=transforms.ToTensor())
x = dataset.data
n = x.shape[0]
x = x.reshape(n, -1)
n0 = int(0.01 * n)
x = torch.tensor(x[:n0], dtype=torch.float32)
X_tsne = TSNE(n_components=2, perplexity=10, n_iter=250,
verbose=True).fit_transform(x)
print(X_tsne)
This gives a series of nan
s. However, if we use sklearn instead (as commented in the original code), this gives some meaningful results.
Could you please figure out why this is the case?
Hello,
As i understand , this line deals with imaginary eigenvalues, and creates real eigenvectors in M. according to the torch documentation for eig, the suggestion is to perform linear combinations of the ith and i+1th initial eigenvectors to get the real eigenvectors. however in the code there seems to just be a reassignment, which will still leave M[:,i] complex if it was originally so ( because then M[:,i+1] would have been complex as well)
can you please verify this line is correct?
Hello,I have a question when I run (l, M) = torch.eig(torch.mm(X.t(), X), True)
,sometimes the program is stuck,Is this a torch version issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.