Created
July 9, 2018 11:07
-
-
Save siakon89/084b6a66926f3fb84689f0d26c36f37f 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
def split_train_test(train): | |
np.random.shuffle(train) | |
features = [x[0] for x in train] | |
labels = [x[1] for x in train] | |
# Split the dataset to train and validation | |
x_train, x_test, y_train, y_test = train_test_split(features, labels, test_size=0.025, random_state=42) | |
# One-hot Encoding | |
y_train = np_utils.to_categorical(y_train, 10) | |
y_test = np_utils.to_categorical(y_test, 10) | |
return (np.array(x_train), y_train), (np.array(x_test), y_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment