I'm trying to adapt Aymeric Damien's code to visualize the dimensionality reduction performed by an autoencoder implemented in TensorFlow . All of the examples I have seen work on the mnist digits dataset but I wanted to use this method to visualize the iris dataset in 2 dimensions as a toy example so I can figure out how to tweak it for my real-world datasets.

My question is: How can one get the sample-specific 2 dimensional embeddings to visualize?

For example, the iris dataset has 150 samples with 4 attributes . I added 4 noise attributes to get a total of 8 attributes . The encoding/decoding follows: [8, 4, 2, 4, 8] but I'm not sure how to extract an array of shape (150, 2) to visualize the embeddings. I haven't found any tutorials on how to visualize the dimensionality reduction using TensorFlow .

from sklearn.datasets import load_iris from sklearn.decomposition import PCA import numpy as np import tensorflow as tf import matplotlib.pyplot as plt %matplotlib inline # Set random seeds np.random.seed(0) tf.set_random_seed(0) # Load data iris = load_iris() # Original Iris : (150,4) X_iris = iris.data # Iris with noise : (150,8) X_iris_with_noise = np.concatenate([X_iris, np.random.random(size=X_iris.shape)], axis=1).astype(np.float32) y_iris = iris.target # PCA pca_xy = PCA(n_components=2).fit_transform(X_iris_with_noise) with plt.style.context("seaborn-white"): fig, ax = plt.subplots() ax.scatter(pca_xy[:,0], pca_xy[:,1], c=y_iris, cmap=plt.cm.Set2) ax.set_title("PCA | Iris with noise")