Monday, October 11, 2021

Down The Uncanny Valley

The uncanny valley is the abrupt dip in human affinity to a non-human creature when we see it approaching human-like characteristics. For instance, the spooky feeling when one looks at Sofia the robot or  Lil Miquela the Instagram influencer. Really though, Lil Miquela gives me the creeps when I go through her timeline. It is the eeriness of a realistic face with personalized captions with her sense of awareness that she is not a real person that is quite unsettling. 

Album Cover

Although, Artificial Intelligence amazes me all the time. There is something surreal about it that makes working with it exciting. Of course, we can peel off the layers and see the maths behind them. Get to the matrices and tensor to understand how these neurons work. Even get the values of weights and biases and assure ourselves that this is no sorcery. Still, when I see the result play out it is astonishing. They are mysterious and quite understandable at the same time. Nonetheless, It is the emotional uneasiness associated with it that is difficult to process.

When I first decided to build an AI to write song lyrics for me, to my surprise, I was able to get to a working model pretty fast. I will spare you a summary of my personal learning curve and my initial skill set. As that is too resume-ish for the blog's content, some may say. I geek out in my blogs, I mean that's basically what I live for. 

Long story short, the initial "working" Recurrent Neural Network that did generate some output, only generated gibberish. After a few improvements, I reached a model that had real word generation. Although to my dismay, the network appeared to be obsessed with being "born". That was a sneak into the uncanny valley of AI. Fascinating! 

AI's Obsession On Being Born

This Probably was my Victor Frankenstein moment. God's complex or God's conundrum.

After that, refining the model was pretty peachy, The AI wrote an extension of my poems. And I think it was quite thoughtful. Okay, at least it was a bunch of fully-formed meaningful sentences... stuck together mostly out of any context. And that was actually what's expected if we look into the way Recurrent Neural Networks work. 

My Poem Extended By AI

As long as there were words and were arranged together in a manner that would pass as a sentence at first glance; I was proud of my little AI monster. After all, it is just a child in front of the giants, from open AI & hugging face. Those transformer-based models are trained on a ginormous amount of information. The adjective State-of-The-Art is often associated with such models. They have is these delightful websites interfaces where you could just go and type one line to text and In return, they would generate a book for you! I so wish I had that during my academic years. I would have saved so many midnight candles that I burnt on completing the assignments. The assignments that, I still believe, no one ever read.

Getting unstructured sentences from the model, got me thinking; If only language had a set of rules that were slightly less intricate. Maybe had a certain strick pattern ... a sort of key. Like musical compositions have. Like Mozart's Symphony No 40, one of his most popular, in the key of G minor. the symphony is literary known as the great G minor.  

Sound is created by vibrations in the air. There can be infinite kinds of soundwaves as there are infinite combinations of frequencies and amplitudes. In music, we consider pitch and wavelength. As there are infinite soundwaves there can be infinite musical notes. However, contemporary music uses12 unique notes. The 12 notes have a constant difference in frequency with respect to each other. 

Twelve Notes on Piano

Though there are far more keys on a piano, all of them are different versions of those 12 notes on musical instruments. Say in the above image the key of A has a frequency of 220 Hz. The next assortment of keys will be set in a different octave and that A will be of frequency 440 Hz. Each shift in the octave doubles the frequency. 

Twelve Tone Musical Scale

Not all of the notes sound good together, there are a selected set of notes that are used in a song. This set of selected notes are indicative of the Key. When a song is in the key of C Major or D Minor this is simply telling you which of the 12 notes are used in this song.

Back to the initial topic, This sets up an easier pattern for a Recurrent Neural Network to learn than to learn a language with a strict syntax and oh so many exceptions. Besides even if it breaks those rules, I would never know. 

I went further down the valley and made my first AI model generate music. I trained it with Frédéric Chopin's compositions. On second thought I think, Beethoven would have been an ideal candidate. Nonetheless, I did skip over my initial plan to work with Mozart's works... Ugh! What the hell I didn't want to work on data scraping there I said it! So I found this big dataset on Kaggle and Chopin’s was the one with the most files. 

The first output was basically "something" ponding on the same key with one finger at a constant interval of time. It was still an art form, in my opinion, Made me think deep and hard about existence and how we should all be just annihilated right on the instinct the next note is played. The longer I played it the more I was convinced of it 

After making a few tweaks in the architecture of the network It worked alright not as good as Frédéric Chopin's. Still, it is nice. See for yourself. 


On scrutinising the generated melody, as it has a variety of notes; I am quite satisfied. On the enigma, is it a good musical composition; is it artsy? Did the AI create a masterpiece? I don't know! I am not a connoisseur of music. I used a Recurrent Neural Network and it worked alright. I decided to let the AI have the fame it deserved. 

So, I am releasing the album here on this blog! Yey! Don't forget to get your copy!



Get your copy:

 

Afternoon On Pluto

 

Almost A Lovesong (for Zombies)

 

Children's Rhyme By The Clown

 

Homealone In Lockdown

 

Midnight Intruder

 

Netflix and Videocall

 

Secret Stash

 

Up The Infinite Castel

 


Thanks for visiting my Blog; it’s always good to see you here!
Find me on the following: 

·         Twitter
·         Goodreads

Links to my RNN Projects:

Lyrics Generation 

Music Generation

Link To My Notebooks