@@ -69,6 +69,7 @@ def get_notes():
69
69
elif isinstance (element , chord .Chord ):
70
70
notes .append ('.' .join (str (n ) for n in element .normalOrder ))
71
71
72
+ os .makedirs ("data" , exist_ok = True )
72
73
with open ('data/notes' , 'wb' ) as filepath :
73
74
pickle .dump (notes , filepath )
74
75
@@ -112,18 +113,17 @@ def prepare_sequences(notes, n_vocab):
112
113
def create_network (network_input , n_vocab ):
113
114
""" create the structure of the neural network """
114
115
model = tf .keras .Sequential ()
115
- model .add (tf .keras .layers .GRU (
116
- 256 ,
116
+ model .add (tf .keras .layers .CuDNNGRU (
117
+ 128 ,
117
118
input_shape = (network_input .shape [1 ], network_input .shape [2 ]),
118
119
return_sequences = True
119
120
))
120
- model .add (tf .keras .layers .Dropout (0.3 ))
121
- model .add (tf .keras .layers .GRU (128 , return_sequences = True ))
122
- model .add (tf .keras .layers .Dropout (0.3 ))
123
- model .add (tf .keras .layers .GRU (64 ))
124
- model .add (tf .keras .layers .Dense (256 ))
121
+ model .add (tf .keras .layers .CuDNNGRU (64 , return_sequences = True ))
122
+ model .add (tf .keras .layers .CuDNNGRU (32 ))
123
+ model .add (tf .keras .layers .Dense (128 , activation = "relu" ))
125
124
model .add (tf .keras .layers .Dropout (0.3 ))
126
125
model .add (tf .keras .layers .Dense (n_vocab ))
126
+ model .add (tf .keras .layers .Dropout (0.3 ))
127
127
model .add (tf .keras .layers .Activation ('softmax' ))
128
128
model .compile (loss = 'categorical_crossentropy' , optimizer = 'rmsprop' )
129
129
@@ -156,8 +156,8 @@ def generate_notes(self, network_input, pitchnames, n_vocab):
156
156
pattern = list (network_input [start ])
157
157
prediction_output = []
158
158
159
- # generate 500 notes
160
- for note_index in range (500 ):
159
+ # generate 200 notes
160
+ for note_index in range (200 ):
161
161
prediction_input = np .reshape (pattern , (1 , len (pattern ), 1 ))
162
162
prediction_input = prediction_input / float (n_vocab )
163
163
0 commit comments