SlideShare a Scribd company logo
ALGORITHMIC
MUSIC
GENERATION
PadmajaV Bhagwat
3rd year, B.Tech, IT, NITK Surathkal. 01
25th Sept, 2016PyCon India 2016
Unnati Data
Labswww.unnati.xyz
Acknowledgement:
My team members
1. Chandana NT
2. Anirudh Sriram
3. Subramaniam Thirunavakkarasu
Under the guidance of
1. Nischal HP
2. Bargava Subramanian
3. Amit Kapoor
4. Raghotam Sripadraj 02
What are
Artificial
Neural
Networks?
 It is biologically-inspired programming paradigm
which enables a computer to learn from
observational data.
 It resembles human brains mainly these two ways
1. A neural network acquires knowledge through
learning.
2. A neural network’s knowledge is stored within
the interconnection strengths known as synaptic
weight.
03
sample #2
sample #1
Using AI to
generate
Music.
Can you
tell the
difference?
04
How to
make
computer to
generate
music?
Step 1: Converting Mp3 files to np-tensors
Step 2:Traing the model
Step 3: Generating the music
05
Uncompress
the music:
mp3 to
monaural
WAV using
LAME cmd = 'lame -a -m m {0} {1}'.format(
quote(filename), quote(filename_tmp))
os.system(cmd)
06
Converting
to Numpy
array.
These are divided into blocks of equal size
by zero padding it.
07
Convert
from time to
frequency
domain
Convert from the time domain to its
corresponding frequency domain using a
Discrete Fourier Transform.
08
Can we
use
traditional
RNN?
Drawback: They cannot retain information for
long periods of time.
RNNs have loops.
 Allows persistence of information.
 Each neuron accepts the input from
previous layer as well as from previous
neuron in the same layer.
09
Can we
make it
remember
for longer
period of
time?
Yes we can! By using
LSTM networks.
10
What are
LSTM
Networks?
Long Short Term Memory
Special type of RNN.
Capable of learning long term dependencies.
It is well-suited to learn from experience to
classify, process and predict time series when
there are very long time lags of unknown size
between important events.
Explicitly designed to avoid the long-term
dependency problem
11
Let’s
understand
its
architecture.
12
This is how it looks!
A separate vector called
cell state is dedicated to
remember information.
Advantage: Number of
parameters that it needs to
learn is less compared to
traditional networks.
13
Step 1:  The first step in LSTM is to decide what
information we’re going to throw away from the cell
state.
 This decision is made by a sigmoid layer called the
“forget gate layer”.
14
Step 2:  Decide what new information we’re going to store
in the cell state.
 This has two parts:
1. A sigmoid layer called the “input gate layer”
decides which values we’ll update.
2. A tanh layer creates a vector of new candidate
values, Ct that could be added to the state
15
Step 3:
we update the old cell state Ct-1 to the new cell state Ct
16
Step 4:  we need to decide what we’re going to output.
 Sigmoid layer decides what parts of the cell states
we are going to output.
 The updated cell state vector is passed through a
tanh layer and multiply it by the output of the
sigmoid gate.
17
Training
the
model:
 Input data is given to the input of the network,
which then fires all the corresponding neurons.
 The LSTM generates a sequence of notes which is
compared against the expected output and the
errors are back-propagated, thus adjusting the
parameters learnt by the LSTM.
After shifting
18
The vector used for computing loss function is same as the input layers but shifted by 1 block.
Training
the
model:
 The optimizer used is 'rms-prop' and the loss
function used is 'mean squared error‘.
 The learnt parameters are stored in a file, that is
further used in generation phase.
19
Model =
network_utils.create_lstm_network(num_freque
ncy_dimensions=freq_space_dims,
num_hidden_dimensions=hidden_dims)
#hidden_dims=1024
Generation
phase:
 Step 1 - Given A = [X0, X1, ... Xn], generate Xn + 1
 Step 2 - Append Xn + 1 to A.
 Step 3 - Repeat Steps 1 and 2 again and again depending on
the length of the music piece user wish to generate.
#We take first chunk of the training data as a seed sequence
seed_len = 1
seed_seq = seed_generator.generate_copy_seed_sequence(seed_length=seed_len, training_data=X_train)
#This defines how long the final song is. Total song length in samples = max_seq_len * example_len
max_seq_len = 10
output = sequence_generator.generate_from_seed(model=model, seed=seed_seq,
sequence_length=max_seq_len, data_variance=X_var, data_mean=X_mean)
20
Challenges!  The music that is generated has to be unique without
infringing the copyrights.
 It has to sound good, and what sounds good is very
subjective.
 Unlike traditional math problem, this cannot be solved
by set of formulae.
 It takes lot of time to train the model in order to make it
generate good music.
21
How long
does it
take?
Well it requires time…
 After about 100 iterations over 20
different music files.
 After 2000 iterations over 20
different music files.
22
Python
Libraries
used:
• Keras version 0.1.0 with Theano as the backend.
• NumPy and SciPy for various mathematical
computation on tensors.
• Matplotlib for visualizing the input.
• LAME and SoX to convert mp3 files into other
formats such as wav.
23
The entire code is on GitHub.
https://github.com/unnati-xyz/music-generation
24
Key notes
for using
this code to
generate
your own
music:
Step 1: Converting the given mp3 files into np
tensors.
python convert_directory.py // creates
YourMusicLibraryNP_x.npy, YourMusicLibraryNP_y.npy
Step 2: Training the model.
python train.py // creates LSTM model
Step 3: Generating the music.
python generate.py // final generated music which is stored
in a file named generated_song.wav.
25
References:
 http://colah.github.io/posts/2015-08-Understanding-LSTMs/
 http://karpathy.github.io/2015/05/21/rnn-effectiveness/
 https://cs224d.stanford.edu/reports/NayebiAran.pdf
 https://www.quora.com/What-is-machine-learning-in-
laymans-terms-1
 http://www.hexahedria.com/2015/08/03/composing-music-
with-recurrent-neural-networks/
Fun at UNNATI! 
THANK YOU! 
CC-Attribution-ShareAlike
https://creativecommons.org/licenses/by-sa/4.0/
www.linkedin.com/in/padmajavb

More Related Content

What's hot

Back propagation
Back propagationBack propagation
Back propagation
Nagarajan
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
Simplilearn
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain RatioLecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Marina Santini
 
Artificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical DiagnosisArtificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical Diagnosis
Adityendra Kumar Singh
 
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
khanam22
 
Clustering
ClusteringClustering
Clustering
M Rizwan Aqeel
 
Feature selection
Feature selectionFeature selection
Feature selection
dkpawar
 
Artifical Neural Network and its applications
Artifical Neural Network and its applicationsArtifical Neural Network and its applications
Artifical Neural Network and its applications
Sangeeta Tiwari
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
Vivek Garg
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
Paras Kohli
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
Megha Sharma
 
Self Organizing Maps
Self Organizing MapsSelf Organizing Maps
Self Organizing Maps
Daksh Raj Chopra
 
Support vector machines (svm)
Support vector machines (svm)Support vector machines (svm)
Support vector machines (svm)
Sharayu Patil
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
Neha Kulkarni
 
K means Clustering Algorithm
K means Clustering AlgorithmK means Clustering Algorithm
K means Clustering Algorithm
Kasun Ranga Wijeweera
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
Atul Krishna
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
Akash Goel
 
K means clustering
K means clusteringK means clustering
K means clustering
keshav goyal
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
zamakhan
 

What's hot (20)

Back propagation
Back propagationBack propagation
Back propagation
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain RatioLecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
 
Artificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical DiagnosisArtificial Neural Network in Medical Diagnosis
Artificial Neural Network in Medical Diagnosis
 
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
 
Clustering
ClusteringClustering
Clustering
 
Feature selection
Feature selectionFeature selection
Feature selection
 
Artifical Neural Network and its applications
Artifical Neural Network and its applicationsArtifical Neural Network and its applications
Artifical Neural Network and its applications
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
 
Local search algorithm
Local search algorithmLocal search algorithm
Local search algorithm
 
Self Organizing Maps
Self Organizing MapsSelf Organizing Maps
Self Organizing Maps
 
Support vector machines (svm)
Support vector machines (svm)Support vector machines (svm)
Support vector machines (svm)
 
K-Nearest Neighbor Classifier
K-Nearest Neighbor ClassifierK-Nearest Neighbor Classifier
K-Nearest Neighbor Classifier
 
K means Clustering Algorithm
K means Clustering AlgorithmK means Clustering Algorithm
K means Clustering Algorithm
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
 
backpropagation in neural networks
backpropagation in neural networksbackpropagation in neural networks
backpropagation in neural networks
 
K means clustering
K means clusteringK means clustering
K means clustering
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 

Similar to Algorithmic music generation

Lab 6 Neural Network
Lab 6 Neural NetworkLab 6 Neural Network
Lab 6 Neural Network
Kyle Villano
 
Plant recognition system
Plant recognition systemPlant recognition system
Plant recognition system
Sinisa Vukovic
 
Artifical Neural Network
Artifical Neural NetworkArtifical Neural Network
Artifical Neural Network
mahalakshmimalini
 
Deep learning
Deep learningDeep learning
Deep learning
Khaled AMIRAT
 
Algorithmic Music Generation
Algorithmic Music GenerationAlgorithmic Music Generation
Algorithmic Music Generation
Padmaja Bhagwat
 
5th_sem_presentationtoday.pdf
5th_sem_presentationtoday.pdf5th_sem_presentationtoday.pdf
5th_sem_presentationtoday.pdf
satyaprakashkumawat2
 
Som paper1.doc
Som paper1.docSom paper1.doc
Som paper1.doc
Abhi Mediratta
 
Machine learning_ Replicating Human Brain
Machine learning_ Replicating Human BrainMachine learning_ Replicating Human Brain
Machine learning_ Replicating Human Brain
Nishant Jain
 
Artificial Neural networks
Artificial Neural networksArtificial Neural networks
Artificial Neural networks
Learnbay Datascience
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
Ismail El Gayar
 
IRJET - Music Generation using Deep Learning
IRJET -  	  Music Generation using Deep LearningIRJET -  	  Music Generation using Deep Learning
IRJET - Music Generation using Deep Learning
IRJET Journal
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
mustafa aadel
 
Open CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural NetworksOpen CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural Networks
ijceronline
 
lecture11_Artificial neural networks.ppt
lecture11_Artificial neural networks.pptlecture11_Artificial neural networks.ppt
lecture11_Artificial neural networks.ppt
j7757652020
 
ppt document 5b6 presentation based on education.pptx
ppt document 5b6 presentation based on education.pptxppt document 5b6 presentation based on education.pptx
ppt document 5b6 presentation based on education.pptx
20nu1a05b6
 
Deep learning - Chatbot
Deep learning - ChatbotDeep learning - Chatbot
Deep learning - Chatbot
Liam Bui
 
Deep learning tutorial 9/2019
Deep learning tutorial 9/2019Deep learning tutorial 9/2019
Deep learning tutorial 9/2019
Amr Rashed
 
Deep Learning Tutorial
Deep Learning TutorialDeep Learning Tutorial
Deep Learning Tutorial
Amr Rashed
 
Artificial_Neural_Network.pdf
Artificial_Neural_Network.pdfArtificial_Neural_Network.pdf
Artificial_Neural_Network.pdf
ssuser136534
 
Artificial Intelligence, Machine Learning and Deep Learning with CNN
Artificial Intelligence, Machine Learning and Deep Learning with CNNArtificial Intelligence, Machine Learning and Deep Learning with CNN
Artificial Intelligence, Machine Learning and Deep Learning with CNN
mojammel43
 

Similar to Algorithmic music generation (20)

Lab 6 Neural Network
Lab 6 Neural NetworkLab 6 Neural Network
Lab 6 Neural Network
 
Plant recognition system
Plant recognition systemPlant recognition system
Plant recognition system
 
Artifical Neural Network
Artifical Neural NetworkArtifical Neural Network
Artifical Neural Network
 
Deep learning
Deep learningDeep learning
Deep learning
 
Algorithmic Music Generation
Algorithmic Music GenerationAlgorithmic Music Generation
Algorithmic Music Generation
 
5th_sem_presentationtoday.pdf
5th_sem_presentationtoday.pdf5th_sem_presentationtoday.pdf
5th_sem_presentationtoday.pdf
 
Som paper1.doc
Som paper1.docSom paper1.doc
Som paper1.doc
 
Machine learning_ Replicating Human Brain
Machine learning_ Replicating Human BrainMachine learning_ Replicating Human Brain
Machine learning_ Replicating Human Brain
 
Artificial Neural networks
Artificial Neural networksArtificial Neural networks
Artificial Neural networks
 
Neural Networks
Neural NetworksNeural Networks
Neural Networks
 
IRJET - Music Generation using Deep Learning
IRJET -  	  Music Generation using Deep LearningIRJET -  	  Music Generation using Deep Learning
IRJET - Music Generation using Deep Learning
 
Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Open CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural NetworksOpen CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural Networks
 
lecture11_Artificial neural networks.ppt
lecture11_Artificial neural networks.pptlecture11_Artificial neural networks.ppt
lecture11_Artificial neural networks.ppt
 
ppt document 5b6 presentation based on education.pptx
ppt document 5b6 presentation based on education.pptxppt document 5b6 presentation based on education.pptx
ppt document 5b6 presentation based on education.pptx
 
Deep learning - Chatbot
Deep learning - ChatbotDeep learning - Chatbot
Deep learning - Chatbot
 
Deep learning tutorial 9/2019
Deep learning tutorial 9/2019Deep learning tutorial 9/2019
Deep learning tutorial 9/2019
 
Deep Learning Tutorial
Deep Learning TutorialDeep Learning Tutorial
Deep Learning Tutorial
 
Artificial_Neural_Network.pdf
Artificial_Neural_Network.pdfArtificial_Neural_Network.pdf
Artificial_Neural_Network.pdf
 
Artificial Intelligence, Machine Learning and Deep Learning with CNN
Artificial Intelligence, Machine Learning and Deep Learning with CNNArtificial Intelligence, Machine Learning and Deep Learning with CNN
Artificial Intelligence, Machine Learning and Deep Learning with CNN
 

Recently uploaded

一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
bmucuha
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
uevausa
 
Econ3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdfEcon3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdf
blueshagoo1
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 
Drownings spike from May to August in children
Drownings spike from May to August in childrenDrownings spike from May to August in children
Drownings spike from May to August in children
Bisnar Chase Personal Injury Attorneys
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
22ad0301
 
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdfreading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
perranet1
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
Vineet
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
Vineet
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
z6osjkqvd
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
Vietnam Cotton & Spinning Association
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
dataschool1
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
agdhot
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
MastanaihnaiduYasam
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Marlon Dumas
 
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
osoyvvf
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
hqfek
 

Recently uploaded (20)

一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
Econ3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdfEcon3060_Screen Time and Success_ final_GroupProject.pdf
Econ3060_Screen Time and Success_ final_GroupProject.pdf
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 
Drownings spike from May to August in children
Drownings spike from May to August in childrenDrownings spike from May to August in children
Drownings spike from May to August in children
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
 
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdfreading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
 
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
 

Algorithmic music generation

  • 1. ALGORITHMIC MUSIC GENERATION PadmajaV Bhagwat 3rd year, B.Tech, IT, NITK Surathkal. 01 25th Sept, 2016PyCon India 2016
  • 2. Unnati Data Labswww.unnati.xyz Acknowledgement: My team members 1. Chandana NT 2. Anirudh Sriram 3. Subramaniam Thirunavakkarasu Under the guidance of 1. Nischal HP 2. Bargava Subramanian 3. Amit Kapoor 4. Raghotam Sripadraj 02
  • 3. What are Artificial Neural Networks?  It is biologically-inspired programming paradigm which enables a computer to learn from observational data.  It resembles human brains mainly these two ways 1. A neural network acquires knowledge through learning. 2. A neural network’s knowledge is stored within the interconnection strengths known as synaptic weight. 03
  • 4. sample #2 sample #1 Using AI to generate Music. Can you tell the difference? 04
  • 5. How to make computer to generate music? Step 1: Converting Mp3 files to np-tensors Step 2:Traing the model Step 3: Generating the music 05
  • 6. Uncompress the music: mp3 to monaural WAV using LAME cmd = 'lame -a -m m {0} {1}'.format( quote(filename), quote(filename_tmp)) os.system(cmd) 06
  • 7. Converting to Numpy array. These are divided into blocks of equal size by zero padding it. 07
  • 8. Convert from time to frequency domain Convert from the time domain to its corresponding frequency domain using a Discrete Fourier Transform. 08
  • 9. Can we use traditional RNN? Drawback: They cannot retain information for long periods of time. RNNs have loops.  Allows persistence of information.  Each neuron accepts the input from previous layer as well as from previous neuron in the same layer. 09
  • 10. Can we make it remember for longer period of time? Yes we can! By using LSTM networks. 10
  • 11. What are LSTM Networks? Long Short Term Memory Special type of RNN. Capable of learning long term dependencies. It is well-suited to learn from experience to classify, process and predict time series when there are very long time lags of unknown size between important events. Explicitly designed to avoid the long-term dependency problem 11
  • 13. This is how it looks! A separate vector called cell state is dedicated to remember information. Advantage: Number of parameters that it needs to learn is less compared to traditional networks. 13
  • 14. Step 1:  The first step in LSTM is to decide what information we’re going to throw away from the cell state.  This decision is made by a sigmoid layer called the “forget gate layer”. 14
  • 15. Step 2:  Decide what new information we’re going to store in the cell state.  This has two parts: 1. A sigmoid layer called the “input gate layer” decides which values we’ll update. 2. A tanh layer creates a vector of new candidate values, Ct that could be added to the state 15
  • 16. Step 3: we update the old cell state Ct-1 to the new cell state Ct 16
  • 17. Step 4:  we need to decide what we’re going to output.  Sigmoid layer decides what parts of the cell states we are going to output.  The updated cell state vector is passed through a tanh layer and multiply it by the output of the sigmoid gate. 17
  • 18. Training the model:  Input data is given to the input of the network, which then fires all the corresponding neurons.  The LSTM generates a sequence of notes which is compared against the expected output and the errors are back-propagated, thus adjusting the parameters learnt by the LSTM. After shifting 18 The vector used for computing loss function is same as the input layers but shifted by 1 block.
  • 19. Training the model:  The optimizer used is 'rms-prop' and the loss function used is 'mean squared error‘.  The learnt parameters are stored in a file, that is further used in generation phase. 19 Model = network_utils.create_lstm_network(num_freque ncy_dimensions=freq_space_dims, num_hidden_dimensions=hidden_dims) #hidden_dims=1024
  • 20. Generation phase:  Step 1 - Given A = [X0, X1, ... Xn], generate Xn + 1  Step 2 - Append Xn + 1 to A.  Step 3 - Repeat Steps 1 and 2 again and again depending on the length of the music piece user wish to generate. #We take first chunk of the training data as a seed sequence seed_len = 1 seed_seq = seed_generator.generate_copy_seed_sequence(seed_length=seed_len, training_data=X_train) #This defines how long the final song is. Total song length in samples = max_seq_len * example_len max_seq_len = 10 output = sequence_generator.generate_from_seed(model=model, seed=seed_seq, sequence_length=max_seq_len, data_variance=X_var, data_mean=X_mean) 20
  • 21. Challenges!  The music that is generated has to be unique without infringing the copyrights.  It has to sound good, and what sounds good is very subjective.  Unlike traditional math problem, this cannot be solved by set of formulae.  It takes lot of time to train the model in order to make it generate good music. 21
  • 22. How long does it take? Well it requires time…  After about 100 iterations over 20 different music files.  After 2000 iterations over 20 different music files. 22
  • 23. Python Libraries used: • Keras version 0.1.0 with Theano as the backend. • NumPy and SciPy for various mathematical computation on tensors. • Matplotlib for visualizing the input. • LAME and SoX to convert mp3 files into other formats such as wav. 23
  • 24. The entire code is on GitHub. https://github.com/unnati-xyz/music-generation 24
  • 25. Key notes for using this code to generate your own music: Step 1: Converting the given mp3 files into np tensors. python convert_directory.py // creates YourMusicLibraryNP_x.npy, YourMusicLibraryNP_y.npy Step 2: Training the model. python train.py // creates LSTM model Step 3: Generating the music. python generate.py // final generated music which is stored in a file named generated_song.wav. 25
  • 26. References:  http://colah.github.io/posts/2015-08-Understanding-LSTMs/  http://karpathy.github.io/2015/05/21/rnn-effectiveness/  https://cs224d.stanford.edu/reports/NayebiAran.pdf  https://www.quora.com/What-is-machine-learning-in- laymans-terms-1  http://www.hexahedria.com/2015/08/03/composing-music- with-recurrent-neural-networks/