I'm not certain if my error lies in my understanding of python's sklearn or of t-SNE, but I have (essentially), the following code:
import numpy as np
from sklearn.manifold import TSNE
...
latent_codes = np.asarray(latent_codes)
model = TSNE(n_components=2, random_state=0)
targets = model.fit_transform(latent_codes)
import pdb
pdb.set_trace()
Now, when I take advantage of pdb to examine latent_codes, I find it's a 40x50 zero matrix:
(Pdb) latent_codes.shape
(40, 50)
(Pdb) latent_codes
array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
...,
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]])
(Pdb) np.count_nonzero(latent_codes)
0
However, the targets produced by model_fit_transform
are all different:
(Pdb) targets
array([[ -68.17034118, 59.8387551 ],
[ 154.31303231, -65.25843496],
[-116.26644151, -19.97313287],
[ 25.15679123, -96.2950044 ],
[ -21.30201657, 15.49542397],
[ 117.35081217, 44.15759738],
[ -82.23108406, -48.82985134],
[-113.48912279, 26.86769182],
[ 63.0661867 , -77.18010188],
[-214.31557952, 186.65681657],
[ 41.81882958, 128.70962697],
[ 4.56304673, -14.75060863],
[ -64.14735674, 21.53516755],
[ -51.69388635, -159.27904258],
[ -47.77084845, -115.1462873 ],
[ 131.90001156, -6.43364854],
[ -0.83806249, -128.14477442],
[-296.70119624, -119.19975211],
[ -46.69551791, 95.57097896],
[ 5.87913502, 94.59336748],
[ 20.06775981, 29.26705814],
[ 50.24510794, 1.10575949],
[ 35.81033393, -41.01231103],
[ 273.79224551, 198.21000606],
[ -28.41723332, -40.45356725],
[-109.32362451, 82.86647462],
[ 133.32828608, 97.65628466],
[-108.9115903 , -87.49420981],
[ -48.84660715, -76.67380263],
[ 14.60874986, -173.3446314 ],
[ 80.21260263, -28.05786872],
[ 66.4516378 , -128.04476666],
[ 73.15296956, 35.96795971],
[ 80.93310524, 91.51665493],
[ -56.73663254, -15.00847778],
[ 106.25595116, -67.73558382],
[ 0.01308238, -66.19634508],
[ -16.16269284, 56.56122915],
[ -24.14615918, 136.37358297],
[ 40.32559439, 67.55044349]])
If I'm trying to project the same 50-dim point to a 2-dim space 40 times, shouldn't I get the same 2-dim point 40 times?