Created
April 8, 2020 22:37
-
-
Save codingsnap/ad27995c371405c0876e3368b042d51c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sequence_length = 100 | |
network_input = [] | |
for i in range(len(notes) - sequence_length): | |
seq_in = notes[i : i+sequence_length] # contains 100 values | |
network_input.append([ele_to_int[ch] for ch in seq_in]) | |
# Any random start index | |
start = np.random.randint(len(network_input) - 1) | |
# Mapping int_to_ele | |
int_to_ele = dict((num, ele) for num, ele in enumerate(pitchnames)) | |
# Initial pattern | |
pattern = network_input[start] | |
prediction_output = [] | |
# generate 200 elements | |
for note_index in range(200): | |
prediction_input = np.reshape(pattern, (1, len(pattern), 1)) # convert into numpy desired shape | |
prediction_input = prediction_input/float(n_vocab) # normalise | |
prediction = model.predict(prediction_input, verbose=0) | |
idx = np.argmax(prediction) | |
result = int_to_ele[idx] | |
prediction_output.append(result) | |
# Remove the first value, and append the recent value.. | |
# This way input is moving forward step-by-step with time.. | |
pattern.append(idx) | |
pattern = pattern[1:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment