Skip to content

Instantly share code, notes, and snippets.

@rish-16
Last active May 19, 2018 12:55
Show Gist options
  • Save rish-16/af5dfe580893665413a3de0b3d04eb8a to your computer and use it in GitHub Desktop.
Save rish-16/af5dfe580893665413a3de0b3d04eb8a to your computer and use it in GitHub Desktop.
Cat Faces dataset preprocessing function
import numpy as np
from sklearn.model_selection import train_test_split
def load_cats():
cats = np.load("./cats.npy")
print (cats.shape)
Y = []
for i in range(cats.shape[0]):
Y.append([1,0])
Y = np.array(Y)
(x_train, y_train, x_test, y_test) = train_test_split(cats, Y)
x_train = (x_train.astype(np.float32)) / 255
x_train = x_train.reshape(x_train.shape[0], 784)
return (x_train, y_train, x_test, y_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment