Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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