Skip to content

Instantly share code, notes, and snippets.

@irdanish11
Created October 16, 2019 08:35
Show Gist options
  • Select an option

  • Save irdanish11/99841a2d79c4ab4fa0904409d8556ba7 to your computer and use it in GitHub Desktop.

Select an option

Save irdanish11/99841a2d79c4ab4fa0904409d8556ba7 to your computer and use it in GitHub Desktop.
Splits the sequences into inputs and output labels for our model. As sequence length was 4, we use first three words and for that three words model will predict the word. The fourth word will be used as label. After that we convert our output labels into one hot vectors i.e into combinations of 0's and 1.
train_inputs = n_sequences[:,:-1]
train_targets = n_sequences[:,-1]
train_targets = to_categorical(train_targets, num_classes=vocabulary_size+1)
seq_len = train_inputs.shape[1]
train_inputs.shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment