Skip to content

Instantly share code, notes, and snippets.

@siakon89
Created July 9, 2018 11:07
Show Gist options
  • Save siakon89/084b6a66926f3fb84689f0d26c36f37f to your computer and use it in GitHub Desktop.
Save siakon89/084b6a66926f3fb84689f0d26c36f37f to your computer and use it in GitHub Desktop.
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