A Pytorch Implementation of LSTM-based musical model to generate piano'notes.
- Introduction
- Setup
- Nottingham' Dataset
- Run the code
- Training
- Sample Generation
- Play with the model
- Connect with me
- License
This is a PyTorch Implementation for an LSTM-based Music model that generates piano' notes using Nottingham' Dataset. You can download the dataset from here.
The Nottingham Music Database contains over 1000 Folk Tunes stored in a special text format. The dataset has been converted to a piano-roll format to be easily processed and visualised. Here is a sample from the dataset that you can listen to:
The code is using pipenv
as a virtual environment and package manager. To run the code, all you need is to install the necessary dependencies. open the terminal and type:
git clone https://github.com/Khamies/PianoNotes-LSTM-Generation.git
cd PianoNotes-LSTM-Generation
pipenv install
And you should be ready to go to play with code and build upon it!
- To train the model, run:
python main.py
- To train the model with specific arguments, run:
python main.py --batch_size=64
. The following command-line arguments are available:- Batch size:
--batch_size
- Learning rate:
--lr
- Embedding size:
--embed_size
- Hidden size:
--hidden_size
- Latent size:
--latent_size
- Batch size:
The model is trained on 20 epochs
using Adam as an optimizer with a learning rate = 0.001
and batch size = 32
, you can find all the model settings in settings.py. Here is the loss curve for the training step:
Here is a generated sample from the model, you can listen to it here:
To play with the model, a jupyter notebook has been provided, you can find it here
@misc{Khamies2021PianoNotes-LSTM-Generation, author = {Khamies, Waleed}, title = {A PyTorch Implementation for an LSTM-based Piano model}, year = {2021}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{https://github.com/Khamies/PianoNotes-LSTM-Generation}}, }
For any question or a collaboration, drop me a message here
Follow me on Linkedin!
Thank you ❤️