Skip to content

Instantly share code, notes, and snippets.

@saurabhpal97
Created May 30, 2019 10:28
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 saurabhpal97/b0a8c4d43b5ef0466507749b21a5608d to your computer and use it in GitHub Desktop.
Save saurabhpal97/b0a8c4d43b5ef0466507749b21a5608d to your computer and use it in GitHub Desktop.
#importing the required libraries
from keras.datasets import cifar10
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncoder
#instantiating the OneHotEncoder
enc = OneHotEncoder()
#loading the CIFAR 10 dataset
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
enc.fit(y_train)
#converting labels to one hot vectors
y_train = enc.transform(y_train)
y_test = enc.transform(y_test)
#splitting into training and validation sets
x_train,x_val,y_train,y_val = train_test_split(x_train,y_train,test_size=0.2,random_state=42)
#converting all data to range 0-1
x_train = x_train/255
x_val = x_val/255
x_test = x_test/255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment