Skip to content

Instantly share code, notes, and snippets.

@UrusuLambda
Created August 14, 2020 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UrusuLambda/6e24c7f0114466146bb99d80c1c02285 to your computer and use it in GitHub Desktop.
Save UrusuLambda/6e24c7f0114466146bb99d80c1c02285 to your computer and use it in GitHub Desktop.
import tensorflow as tf
import numpy as np
#For 3D Plot
import pandas as pd
import plotly.express as px
#For PCA
from sklearn.decomposition import PCA
#For t-SNE
from sklearn.manifold import TSNE
#For UMAP
import umap
# Prepare MNIST data.
from tensorflow.keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = np.array(x_train, np.float32), np.array(x_test, np.float32)
x_train, x_test = x_train / 255., x_test / 255.
#reshape to (60000, 784) and (10000, 784)
x_train_shape = x_train.shape
x_train = x_train.reshape(x_train_shape[0], x_train_shape[1] * x_train_shape[2])
x_test_shape = x_test.shape
x_test = x_test.reshape(x_test_shape[0], x_test_shape[1] * x_test_shape[2])
#reduce to 1000
x_train = x_train[:1000]
y_train = y_train[:1000]
x_test = x_test[:1000]
y_test = y_test[:1000]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment