Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i in range(int(len(all_text_chars)/SEQUENCE_LENGTH)):
- #Get next sequence of length 57 as input.
- X_sequence = all_text_chars[i*SEQUENCE_LENGTH:(i+1)*SEQUENCE_LENGTH]
- # Convert the above sequence to the integer mapping using our mapping dictionary.
- X_sequence_ix = [char_to_ix[value] for value in X_sequence]
- # Create a skeleton for the input sequence:
- # we create a 2d numpy matrix which has a feature array of 94
- # long for each of the 57 characters in sequence.
- # This way we basically one hot encode our sequences.
- input_sequence = np.zeros((SEQUENCE_LENGTH, NUMBER_FEATURES))
- # The one hot encoding process: we replace a zero with a one
- # on a position in the input sequence which corresponds with the index
- # of a character in our converted array!
- for j in range(SEQUENCE_LENGTH):
- input_sequence[j][X_sequence_ix[j]] = 1.
- # For each spot in X (which stands for each sequence) we
- # fill in our one hot encoded array!
- X[i] = input_sequence
- #Same for y!
- y_sequence = all_text_chars[i*SEQUENCE_LENGTH+1:(i+1)*SEQUENCE_LENGTH+1]
- y_sequence_ix = [char_to_ix[value] for value in y_sequence]
- target_sequence = np.zeros((SEQUENCE_LENGTH, NUMBER_FEATURES))
- for j in range(SEQUENCE_LENGTH):
- target_sequence[j][y_sequence_ix[j]] = 1.
- y[i] = target_sequence
Add Comment
Please, Sign In to add comment