@@ -11,7 +11,7 @@ Modeling and generating sequences of polyphonic music with the RNN-RBM |
11 | 11 | and `restricted Boltzmann machines (RBM) <rbm.html>`_. |
12 | 12 |
|
13 | 13 | .. note:: |
14 | | - The code for this section is available for download here: `rnnrbm.py <../code/rnnrbm.py>`_. |
| 14 | + The code for this section is available for download here: `rnnrbm.py <code/rnnrbm.py>`_. |
15 | 15 |
|
16 | 16 | You will need the modified `Python MIDI package (GPL license) <http://www.iro.umontreal.ca/~lisa/deep/midi.zip>`_ in your ``$PYTHONPATH`` or in the working directory in order to convert MIDI files to and from piano-rolls. |
17 | 17 | The script also assumes that the content of the `Nottingham Database of folk tunes <http://www.iro.umontreal.ca/~lisa/deep/data/Nottingham.zip>`_ has been extracted in the ``../data`` directory. |
@@ -266,7 +266,7 @@ We now have all the necessary ingredients to start training our network on real |
266 | 266 | n_hidden_recurrent) |
267 | 267 |
|
268 | 268 | gradient = T.grad(cost, params, consider_constant=[v_sample]) |
269 | | - updates_train.update(dict((p, p - lr * g) for p, g in zip(params, |
| 269 | + updates_train.update(((p, p - lr * g) for p, g in zip(params, |
270 | 270 | gradient))) |
271 | 271 | self.train_function = theano.function([v], monitor, |
272 | 272 | updates=updates_train) |
@@ -288,7 +288,10 @@ We now have all the necessary ingredients to start training our network on real |
288 | 288 |
|
289 | 289 | assert len(files) > 0, 'Training set is empty!' \ |
290 | 290 | ' (did you download the data files?)' |
291 | | - dataset = [midiread(f, self.r, self.dt).piano_roll for f in files] |
| 291 | + dataset = [midiread(f, self.r, |
| 292 | + self.dt).piano_roll.astype(theano.config.floatX) |
| 293 | + for f in files] |
| 294 | + |
292 | 295 | try: |
293 | 296 | for epoch in xrange(num_epochs): |
294 | 297 | numpy.random.shuffle(dataset) |
|