Created
May 30, 2019 10:28
-
-
Save saurabhpal97/b0a8c4d43b5ef0466507749b21a5608d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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