Instantly share code, notes, and snippets.

Embed
What would you like to do?
maxlen = 500
# Generate split training and testing data (80% training, 20% testing)
x_train, x_test, y_train, y_test = load_encoded_data(data_split=0.8)
# Determine the number of categories + default(i.e. sentence types)
num_classes = np.max(y_train) + 1
# Vectorize the output sentence type classifcations to Keras readable format
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
# Pad the input vectors to ensure a consistent length
x_train = sequence.pad_sequences(x_train, maxlen=maxlen)
x_test = sequence.pad_sequences(x_test, maxlen=maxlen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment