Hi. I’ m doing the t-sne of a test dataset using this code:
for batch_ts, (XTest, YTest) in enumerate(test_loader):
XTest = XTest.to(device)
recon_batch, mu, logvar, latent_space = model(XTest)
tsne = TSNE(3, verbose=0)
tsne_proj = tsne.fit_transform(latent_space.detach().numpy())
cmap = cm.get_cmap('tab20')
fig, ax = plt.subplots(figsize=(8, 8))
num_categories = 7
for lab in range(num_categories):
indices = YTest == lab
ax.scatter(tsne_proj[indices, 0],
tsne_proj[indices, 1],
tsne_proj[indices, 2],
c=np.array(cmap(lab)).reshape(1, 4),
label=lab,
alpha=0.5)
ax.legend(fontsize='large', markerscale=2)
plt.show()
I get this error: need at least one array to concatenate. If I do 2D t-sne, the error disappears.
How can I fix it? And is it possible to perform an animated plot of t-sne?