Midi-AI-Melody-Generator icon indicating copy to clipboard operation
Midi-AI-Melody-Generator copied to clipboard

Running the script results in error.

Open lfuelling opened this issue 8 years ago • 2 comments

Hi,

when I run the file ai-melody-composer.py it results in an error:

Starting to train neural network. . .
Entering loop. . .
Traceback (most recent call last):
  File "ai-melody-composer.py", line 237, in <module>
    trainer.trainEpochs(EPOCHS_PER_CYCLE)
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/supervised/trainers/trainer.py", line 37, in trainEpochs
    self.train(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/supervised/trainers/rprop.py", line 43, in train
    for seq in self.ds._provideSequences():
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/datasets/sequential.py", line 173, in _provideSequences
    return iter(map(list, iter(self)))
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/datasets/sequential.py", line 169, in __iter__
    yield self.getSequenceIterator(i)
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/datasets/sequential.py", line 63, in getSequenceIterator
    return zip(*self.getSequence(index))
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/datasets/sequential.py", line 56, in getSequence
    return [self._getSequenceField(index, l) for l in self.link]
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.3-py2.7.egg/pybrain/datasets/sequential.py", line 45, in _getSequenceField
    return self.getField(field)[seq[index]:]
TypeError: slice indices must be integers or None or have an __index__ method

Since I'm not that into Python, I can't do much with this Stacktrace.

I also tried using other random MIDI files from the internet which results in another error:

Extracting all of pattern[1]
Traceback (most recent call last):
  File "ai-melody-composer.py", line 169, in <module>
    pattern, tick_ar, velocity_ar, pitch_ar = tranverse_all_folders(folder_trans)
  File "ai-melody-composer.py", line 109, in tranverse_all_folders
    pattern = midi.read_midifile(folder_trans + slash + path)
  File "build/bdist.macosx-10.12-x86_64/egg/midi/fileio.py", line 162, in read_midifile
  File "build/bdist.macosx-10.12-x86_64/egg/midi/fileio.py", line 11, in read
  File "build/bdist.macosx-10.12-x86_64/egg/midi/fileio.py", line 20, in parse_file_header
TypeError: Bad header in MIDI file.

I hope you can help me and thanks for your time.

lfuelling avatar Jan 28 '17 13:01 lfuelling

$ python ai-melody-composer.py

Extracting all of pattern[1] training-ground/beethoven_les_adieux_2.mid Converting data to list. . . Data Converted WARNING:root:No fast networks available: No module named _cppbridge Constructing neutral network. . . Starting to train neural network. . . Entering loop. . . Traceback (most recent call last): File "ai-melody-composer.py", line 236, in trainer.trainEpochs(EPOCHS_PER_CYCLE) File "/usr/local/lib/python2.7/dist-packages/pybrain/supervised/trainers/trainer.py", line 37, in trainEpochs self.train(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pybrain/supervised/trainers/rprop.py", line 40, in train for seq in self.ds._provideSequences(): File "/usr/local/lib/python2.7/dist-packages/pybrain/datasets/sequential.py", line 172, in _provideSequences return iter(map(list, iter(self))) File "/usr/local/lib/python2.7/dist-packages/pybrain/datasets/sequential.py", line 60, in getSequenceIterator fields = self.getSequence(index) File "/usr/local/lib/python2.7/dist-packages/pybrain/datasets/sequential.py", line 55, in getSequence return [self._getSequenceField(index, l) for l in self.link] File "/usr/local/lib/python2.7/dist-packages/pybrain/datasets/sequential.py", line 44, in _getSequenceField return self.getField(field)[ravel(self.getField('sequence_index'))[index]:]
TypeError: slice indices must be integers or None or have an index method

i use pybrain==3.3

b4zz4 avatar Mar 11 '17 21:03 b4zz4

For anyone still having this problem: downgrade numpy+mkl to 1.11.3.

notAlaanor avatar Jul 10 '17 07:07 notAlaanor