From 1a041fa6a0a612505d5bb9e776521191c7cc6462 Mon Sep 17 00:00:00 2001 From: fancoo <2680461921@qq.com> Date: Wed, 28 Jun 2017 18:57:53 +0800 Subject: [PATCH] bug fixed. --- generator.py | 9 ++++++--- preprocess.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index f2c0369..0085846 100644 --- a/generator.py +++ b/generator.py @@ -31,8 +31,11 @@ ''' Helper function to sample an index from a probability array ''' def __sample(a, temperature=1.0): a = np.log(a) / temperature - a = np.exp(a) / np.sum(np.exp(a)) - return np.argmax(np.random.multinomial(1, a, 1)) + # a = np.exp(a) / np.sum(np.exp(a)) + # return np.argmax(np.random.multinomial(1, a, 1)) + dist = np.exp(a)/np.sum(np.exp(a)) + choices = range(len(a)) + return np.random.choice(choices, p=dist) ''' Helper function to generate a predicted value from a given matrix ''' def __predict(model, x, indices_val, diversity): @@ -180,7 +183,7 @@ def main(args): N_epochs = 128 # default # i/o settings - data_fn = 'midi/' + 'original_metheny.mid' # 'And Then I Knew' by Pat Metheny + data_fn = 'midi/' + 'original_metheny.mid' # 'And Then I Knew' by Pat Metheny out_fn = 'midi/' 'deepjazz_on_metheny...' + str(N_epochs) if (N_epochs == 1): out_fn += '_epoch.midi' else: out_fn += '_epochs.midi' diff --git a/preprocess.py b/preprocess.py index 3d1c683..d015ffd 100644 --- a/preprocess.py +++ b/preprocess.py @@ -34,7 +34,7 @@ def __parse_midi(data_fn): # Change key signature to adhere to comp_stream (1 sharp, mode = major). # Also add Electric Guitar. melody_voice.insert(0, instrument.ElectricGuitar()) - melody_voice.insert(0, key.KeySignature(sharps=1, mode='major')) + melody_voice.insert(0, key.KeySignature(sharps=1)) # The accompaniment parts. Take only the best subset of parts from # the original data. Maybe add more parts, hand-add valid instruments.