wingedsheep / music-generation-toolbox

Toolbox for generating music
MIT License
31 stars 3 forks source link

TypeError CompoundWordTransformerModel #21

Closed blechturm closed 1 year ago

blechturm commented 1 year ago

Hi @wingedsheep,

Thanks for your efforts in putting this together! I am already playing around with the remi model. Very exciting stuff!

I just tried out the Word Transformer Model and got this error:

Extracted 4202 compound words.
Extracted 2121 compound words.
Extracted 2372 compound words.
Extracted 2621 compound words.
Extracted 2882 compound words.
Extracted 2780 compound words.
Extracted 2378 compound words.
Extracted 2699 compound words.
Extracted 2433 compound words.
Extracted 1522 compound words.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-3-e6f203a26271>](https://localhost:8080/#) in <module>
     10 
     11 # Create and train the model
---> 12 model = CompoundWordTransformerModel(
     13     dictionary=dataset.dictionary,
     14     max_sequence_length=512

TypeError: __init__() got an unexpected keyword argument 'dictionary'

Here is a google colab notebook using your example midi files that should reproduce the error: compound_word_model.ipynb. It is based on the example in your readme.md.

Best Max

blechturm commented 1 year ago

@wingedsheep I think I found the error:

In this script:

https://github.com/wingedsheep/music-generation-toolbox/blob/main/example/compound_word_example.py

the syntax for training a compound word models is slightly different than in readme.md:

model = CompoundWordTransformerModel() model.train(x_train=dataset.data, epochs=50, stop_loss=0.1)

as opposed to:

# Create and train the model model = CompoundWordTransformerModel( dictionary=dataset.dictionary, max_sequence_length=512 )

The former works. I can create a pull request if you want to. Or create new issues if that helps you. I never participated in an open source project before and I am an R guy not a python guy (yet). So please be patient with me :)

I am planning to test all your implementations, if you want I can keep on posting the issues I find. And maybe I'll write some additional example colabs. I think they are pretty useful.

wingedsheep commented 1 year ago

Hi @blechturm. Glad to hear you are enjoying the music generation models.

The example in the readme was indeed wrong, since the CompoundWordTransformerModel does not have a dictionary parameter. I just pushed a change to fix this.

Thanks for helping me out, and feel free to open a pull request if you find something 👍