Having fun with Deep Learning/AI and Indian Classical Music

I am always amazed by people who can create music .Where does one even start when creating a new original melody ? Being a left brain analytical type person growing up, I remember always being fascinated by such artsy and creative endeavours. That’s why I was quite excited when I created my first bit of music ever! . Check out this 30 second piece below 🙂 .

httpss://youtu.be/cx2WLFc9vXE

Now I admit this is very different type of creative process-lets call it “Left Brain Creativity” , but it was still beautiful and a lot of fun. Here is the story.

  1. Ragas in Indian Classical Music : In traditional Indian music there are a set of melodic frameworks called Ragas developed over many centuries which are used as a basis for many songs and tunes. Each raga has some characteristics … e.g. they symbolize different emotions and some ragas are appropriate for morning and others for evening etc. But at the heart of it they are just complex rules on how to weave together the basic motifs – “the notes” which are Indian version of Do,Re, Mi ….
  2. Web Scraping Ragas with The Beautiful Soup : One of the thing I needed was data about many of these Ragas. A lot of the data on web is in human readable format . To get it in a machine readable format there is a python tool called “beautiful soup” that does a great job getting this data in nice tabular form.This basically gave me sequences of notes for each raga organized in sets of 8 notes in a set and 4 sets in 1 piece. Now we are ready for learning some patterns so we can create new ones.
  3. Deep Learning and Dr. Andrew Ng : Most of you would have heard of deep learning or neural networks -a branch of machine learning loosely inspired by how our brain works . As the field of deep learning has progressed and our understanding of the brain has increased, the analogy is becoming a bit of a stretch. In either case its changing the landscape , thanks to some really talented researchers and truly gifted teachers , deep learning is becoming quite accessible to everyone. Deep learning MOOC course on coursera.org by Dr Andrew Ng. (Standord professor and entrepreneur) that i did last year was a big motivation behind this task. I have done Andrew’s Stanford Machine Learning Course CS229 a few years ago which can be painful -has a lot of theory math and proofs that hurt your brain. The deep learning MOOC course is nothing like that, it is math light and made to be accessible to everyone .It has interviews with some of the legends of deep learning and has a lot of fun assignments in python. Also the tools used for deep learning TensorFlow, Keras and PyTorch are open source and free. These are really powerful tools ,heavy artillery of advanced analytics which pre-open source era would have costed hundreds of thousands but available for free to anyone with a laptop and internet.
  4. Recurrent Neural Networks (RNN) and LSTM Architecture: Here is how we are setting up our problem : we are going to show the deep learning model examples of all the Ragas we have and ask it to learn top level patterns that are common across all Ragas .Then we ask it to generate a new pattern given a random seed. At the lowest level its some sequence of notes (21 unique notes ) and the model will be figuring out “rules” on what makes a good sequence. In deep learning there is a family of architecture for time series (sequence) problems called recurrent neural network. The idea is to learn a next note given the previous note. LSTM (Long Short Term Memory) networks take this further by learning not just from the previous note but from 4 or 5 or n notes before. For e.g. the model learns that for if I start with a ‘Do’ then ending with a ‘Do’ or ‘Re’ on position 8 is the way to go.

The beauty about the these deep learning architectures is that the same setup that created this music sequence is also applicable for sequence problems in completely different fields.. e.g. to predict the next event on an insurance claim given the sequence of previous events or in analyzing sentiment of a tweet or predicting customer churn or stock prices.

5. A human in the loop : The last step was to work with my friend Raghu who is trained in Indian classical music and unlike me is very gifted with music. After a few iterations of deep learning , Raghu was actually quite happy with the output. The music created was Raghu playing the deep learning generated tune on his piano. He has keep the notes the same but added the drum beats to make it a little funky.

There are discussions on whether and when we will we have the next AI winter. IMHO just with the deep learning technologies and tools that exist today, even if there are no new breakthroughs. we have enough business problems to solve for 10 years

Leave a Reply

Your email address will not be published. Required fields are marked *