Music Generation using Three-layered LSTM

Vaishali Ingale, Anush Mohan, Divit Adlakha, Krishan Kumar, Mohit Gupta · DOI

Abstract This paper explores the idea of utilising Long Short-Term Memory neural networks (LSTMNN) for the generation of musical sequences in ABC notation. The proposed approach takes ABC notations from the Nottingham dataset and encodes it to be fed as input for the neural networks. The primary objective is to input the neural networks with an arbitrary note, let the network process and augment a sequence based on the note until a good piece of music is produced. Multiple calibrations have been done to amend the parameters of the network for optimal generation. The output is assessed on the basis of rhythm, harmony, and grammar accuracy.

Introduction

Historically, music generation was a manual process involving analogue signals or human-assisted digital tools. As we move toward autonomous creative AI, the challenge lies in building neural architectures that can capture the intricate nuances of harmony, melody, and rhythm without human intervention.

The authors specifically tackle the "vanishing and exploding gradient" problem common in standard Recurrent Neural Networks (RNNs). In the context of music, these gradient issues mean a model might "forget" the beginning of a musical phrase by the time it reaches the end, leading to incoherent compositions. By using LSTMs, the researchers aim to maintain long-term dependencies, ensuring the generated music follows a logical structure.

Methodology

The researchers employed a deep learning approach focused on sequence prediction using a three-layered LSTM architecture. This depth allows the network to learn hierarchical patterns in the music.

Instead of raw audio or MIDI, the authors used ABC notation, a shorthand form of musical notation that uses standard ASCII characters. The music is treated as a text-generation task; a dictionary of 87 unique characters from the dataset was created, integer-encoded, and converted into one-hot encoded binary vectors.

Model architecture and layer summary

The model uses the Adam optimizer and a SoftMax activation function for multi-class classification (predicting which of the 87 characters comes next). To prevent overfitting, Dropout layers were integrated between the LSTM layers. The output sequences are eventually converted into MIDI and MP3 formats for qualitative evaluation.

Datasets and Training

The model was trained using the Nottingham dataset, a well-known collection of folk tunes. The dataset provides a clean source of monophonic melodies in ABC notation. The authors utilized a batch size of 16 and a sequence length of 64 for the training process, which spanned 90 epochs.

Key Insights

  • LSTMs vs. GANs: LSTMs are often superior at "recycling" specific patterns throughout a sequence and avoiding the repetitive "note loops" that can occur in GAN-based models.
  • Music as Language: By treating ABC notation as a sequence of characters, the authors successfully apply Natural Language Processing (NLP) logic to music, suggesting that the "grammar" of a folk tune is structurally similar to written language.
  • Efficiency: The choice of ABC notation significantly reduces computational complexity, allowing a relatively deep model to train effectively.

Results

The model demonstrated strong quantitative performance, reaching 94% accuracy by the end of 90 epochs. The training loss dropped significantly from an initial 1.4359 to a final 0.1737.

Training accuracy over 90 epochs

As shown in the accuracy curve, the model exhibited rapid convergence, jumping from 59% accuracy to 75% by only the 5th epoch. Qualitatively, the authors report that the generated monophonic music is "pleasant to the ear" and maintains the rhythmic and harmonic integrity of the original folk style.

Conclusion and Future Work

While the current model is successful in generating monophonic music, it is limited by its inability to generate chords or multi-instrument arrangements. Future iterations aim to address polyphony. Additionally, expanding the dataset to include a wider variety of genres and instruments would make the output more robust and appreciable to a broader audience. The authors believe further hyperparameter calibration could continue to refine the musicality of the output.

Summary updated

Abstract

This paper explores the idea of utilising Long Short-Term Memory neural networks (LSTMNN) for the generation of musical sequences in ABC notation. The proposed approach takes ABC notations from the Nottingham dataset and encodes it to be fed as input for the neural networks. The primary objective is to input the neural networks with an arbitrary note, let the network process and augment a sequence based on the note until a good piece of music is produced. Multiple calibrations have been done to amend the parameters of the network for optimal generation. The output is assessed on the basis of rhythm, harmony, and grammar accuracy.
BibTeX
@misc{ingale2021music,
  author = {Vaishali Ingale and Anush Mohan and Divit Adlakha and Krishan Kumar and Mohit Gupta},
  title = {{Music Generation using Three-layered LSTM}},
  year = {2021},
  eprint = {2105.09046},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.09046},
}
Figure