Skip to content

Instantly share code, notes, and snippets.

@IlievskiV
Created December 21, 2021 23:36
Show Gist options
  • Save IlievskiV/3736fde2845ab113ac84454fe5f3c429 to your computer and use it in GitHub Desktop.
Save IlievskiV/3736fde2845ab113ac84454fe5f3c429 to your computer and use it in GitHub Desktop.
from keras.datasets import imdb
from keras.preprocessing import sequence
max_features = 20000 # vocabulary size
maxlen = 100 # max length of every input sequence
(x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=max_features)
x_train, y_train = x_train[:2500], y_train[:2500]
x_test, y_test = x_test[:1000], y_test[:1000]
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