Skip to content

Instantly share code, notes, and snippets.

@codingsnap
Created April 8, 2020 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingsnap/7357fd9bf8212fcdfa3c750216e8ab63 to your computer and use it in GitHub Desktop.
Save codingsnap/7357fd9bf8212fcdfa3c750216e8ab63 to your computer and use it in GitHub Desktop.
# Hoe many elements LSTM input should consider
sequence_length = 100
# All unique classes
pitchnames = sorted(set(notes))
# Mapping between ele to int value
ele_to_int = dict( (ele, num) for num, ele in enumerate(pitchnames) )
network_input = []
network_output = []
for i in range(len(notes) - sequence_length):
seq_in = notes[i : i+sequence_length] # contains 100 values
seq_out = notes[i + sequence_length]
network_input.append([ele_to_int[ch] for ch in seq_in])
network_output.append(ele_to_int[seq_out])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment