def computeTSNEProjectionOfLatentSpace(X, encoder, display=True):
# Compute latent space representation
print("Computing latent space projection...")
X_encoded = encoder.predict(X)
# Compute t-SNE embedding of latent space
print("Computing t-SNE embedding...")
tsne = manifold.TSNE(n_components=2, init='pca', random_state=0)
X_tsne = tsne.fit_transform(X_encoded)
# Plot images according to t-sne embedding
if display:
print("Plotting t-SNE visualization...")
fig, ax = plt.subplots()
imscatter(X_tsne[:, 0], X_tsne[:, 1], imageData=X, ax=ax, zoom=0.15)
plt.show()
else:
return X_tsne
# Show dataset images with T-sne projection of pixel space
评论列表
文章目录