Week 6 — Artificial Pianist

Batuhan Orhon
BBM406 Spring 2021 Projects
2 min readMay 24, 2021

How to generate random music?

After completing the training phase, we have got the trained model. We have generated different piano music by using the same trained model. In this title, we have explained how to produce varied music by using the same model. First of all, we have initialized the initial notes that are forty-nine empty notes following one random note. After that, we have calculated the probability of each following note by using these initial notes and trained model. By using this “NumPy.random” library, we have determined the next note by considering their weights. Next phase, we have taken again fifty note but we have updated the initial notes by removing the first element. Thereafter, we have applied the same operation until the maximum number of the notes of the piano music. Then, we have dropped the first fifty notes and the piano notes are ready for the creation of the “midi” file.

https://towardsdatascience.com/generate-piano-instrumental-music-by-using-deep-learning-80ac35cdbd2e

Model Improvement

In the last week, we mentioned that we are not so happy about the results of our first implementation :

https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2F495958977706749101%2F&psig=AOvVaw32Mu2EtzAVuF_d8gA2HKUV&ust=1621883393399000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCNCPn9HA4PACFQAAAAAdAAAAABAE

After that, we decided to change some hyperparameters such as epoch, frequency, batch size of the same model. Again, we didn’t get theresults we want. Here is an example result:

So, we decided to change our model, and implemented a similar model with transformers. While processing we also realized that if we train the model songs with similar styles, results get better. Here are some results :

Note: This one is my favorite…

At this point, our teaching assistant suggested us to use dropout layers between the transformers and that improved our results more than expected.

Here are some results of our last model:

We hope you enjoyed :)

Project Team

Batuhan Orhon

Batuhan Ayvaz

Özge Kökyay

--

--