{"id":20556521,"url":"https://github.com/somjit101/music-generation-lstm","last_synced_at":"2026-05-20T07:32:39.102Z","repository":{"id":179926688,"uuid":"426359836","full_name":"somjit101/Music-Generation-LSTM","owner":"somjit101","description":"A simple application of an LSTM Network to generate original Folk-style music which are aesthetically pleasing for the listener. ","archived":false,"fork":false,"pushed_at":"2021-11-11T16:35:43.000Z","size":76327,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T18:26:37.313Z","etag":null,"topics":["abc-notation","char-rnn","checkpoints","deep-learning","karpathy","keras-tensorflow","lstm","many-to-many","music","music-generation","tensorflow","time-distributed-lstms"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/somjit101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-09T19:29:00.000Z","updated_at":"2021-11-18T21:12:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8c33a96-11b5-4a0a-b20d-359997644590","html_url":"https://github.com/somjit101/Music-Generation-LSTM","commit_stats":null,"previous_names":["somjit101/music-generation-lstm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somjit101%2FMusic-Generation-LSTM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somjit101%2FMusic-Generation-LSTM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somjit101%2FMusic-Generation-LSTM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somjit101%2FMusic-Generation-LSTM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/somjit101","download_url":"https://codeload.github.com/somjit101/Music-Generation-LSTM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242163854,"owners_count":20082224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abc-notation","char-rnn","checkpoints","deep-learning","karpathy","keras-tensorflow","lstm","many-to-many","music","music-generation","tensorflow","time-distributed-lstms"],"created_at":"2024-11-16T03:28:43.391Z","updated_at":"2026-05-20T07:32:34.083Z","avatar_url":"https://github.com/somjit101.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Music Generation using LSTM\nA simple application of a multi-layered LSTM Network to generate original Folk-style music which are aesthetically pleasing for the listener. \n\n## Overview\n\nHere, we have trained a **Many-to-Many LSTM Network** with musical sequences and the corresponding following note sequences found in the musical notation of a piece composed by an artist. As a result, the Network somehow learns to extract a common **'musical quality'** which is preserved in all of the input musical sequences. When we test the network with completely random sequence inputs, the network returns quite interesting and aeshetically pleasing original musical pieces which are completely machine-generated. \n\n## Training and Model Architecture\n\nThere are **86 unique chaaracters** in the ABC notation of the musical sequences used as training data for the LSTM Network. A **sequence of 64 such characters** is used to contruct each of the input sequence used in the training process. To speed up the training process, we train the architecture with **batches of 16 input sequences**. \n\nThe first layer of the architecture is an Embedding layer which maps every input sequence into a **512-dimensional vector**. This is followed by a collection of LSTM layers (**256 cells each**) and Dropout layers. Finally, a **'TimeDistributed'** Dense Layer binds the outputs of the LSTM cells in the last layer into a sequence output with Softmax activation. The **overall architecture** can be clearly seen from the model summary :\n\n\u003cpre\u003e\n_________________________________________________________________\nLayer (type)                 Output Shape              Param #   \n=================================================================\nembedding_1 (Embedding)      (16, 64, 512)             44032     \n_________________________________________________________________\nlstm_1 (LSTM)                (16, 64, 256)             787456    \n_________________________________________________________________\ndropout_1 (Dropout)          (16, 64, 256)             0         \n_________________________________________________________________\nlstm_2 (LSTM)                (16, 64, 256)             525312    \n_________________________________________________________________\ndropout_2 (Dropout)          (16, 64, 256)             0         \n_________________________________________________________________\nlstm_3 (LSTM)                (16, 64, 256)             525312    \n_________________________________________________________________\ndropout_3 (Dropout)          (16, 64, 256)             0         \n_________________________________________________________________\ntime_distributed_1 (TimeDist (16, 64, 86)              22102     \n_________________________________________________________________\nactivation_1 (Activation)    (16, 64, 86)              0         \n=================================================================\nTotal params: 1,904,214\nTrainable params: 1,904,214\nNon-trainable params: 0\n_________________________________________________________________\n\u003c/pre\u003e\n\n\n## The Dataset \n\nWe have used the [Nottingham Music Database](http://abc.sourceforge.net/NMD/) in [**ABC notation**](https://en.wikipedia.org/wiki/ABC_notation) which contains over 1000 folk tunes.\n\n## Usage \n\nAll input data should be placed in the [data](data/) directory. The example [input.txt](data/input.txt) is taken from the [Nottingham Dataset (Cleaned)](https://github.com/jukedeck/nottingham-dataset).\n\nTo train the model with default settings:\n```bash\n$ python train.py\n```\n\nTo sample the model:\n```bash\n$ python sample.py 100\n```\n\nTraining loss/accuracy is stored in [training_log.csv](logs/training_log.csv).\n\nAlso, to prevent the loss of intermediate weights during the training epochs of the model, the weights are saved in the [model](model/) directory. The training process can take a significant amount of time. \n\n## References \n\n* [Karpathy's Implementation of Character-RNN](https://github.com/karpathy/char-rnn)\n* [The effectiveness of RNNs by Karpathy](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)\n* [MIDI Music Generation](https://towardsdatascience.com/how-to-generate-music-using-a-lstm-neural-network-in-keras-68786834d4c5)  \u0026rarr;  [Source Code](https://github.com/Skuldur/Classical-Piano-Composer)\n* [Generating Tabla Music Part 1](https://www.trivedigaurav.com/blog/machines-learn-to-play-tabla/)\n* [Generating Tabla Music Part 2](https://www.trivedigaurav.com/blog/machines-learn-to-play-tabla-part-2/)\n* [RNN-composed Tabla Long Composition](https://soundcloud.com/trivedigaurav/char-rnn-composes-long-composition)\n* [NN for Generating Music - Surveyed Blog](https://medium.com/artists-and-machine-intelligence/neural-nets-for-generating-music-f46dffac21c0)\n* [FolkRNN Irish Folk Music Generator](https://folkrnn.org/)\n* [RNN-composed Piano Music](https://soundcloud.com/sigur-ur-sk-li/neuralnet-music-1)\n* [Google Magenta](https://magenta.tensorflow.org/)\n* [ABC to Sheet Music Converter](https://www.abcjs.net/abcjs-editor.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomjit101%2Fmusic-generation-lstm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomjit101%2Fmusic-generation-lstm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomjit101%2Fmusic-generation-lstm/lists"}