[PYTHON] The story of making a music generation neural network

I made a music generation neural network using my own MIDI parser and LSTM. Recently, there is a project like Magenta, and it seems to be the nth brew, but when I modified the sampling method from the output probability distribution, a little interesting result was obtained. I got it, so I'll share it.

Demo (* Note the volume for immediate playback) Repository

LSTM It is a kind of neural network that can learn the context of sequential data. For details, I will leave it to the many good articles. The following is detailed.

-Unreasonable effectiveness of recurrent neural networks (translation) --An article by Andrej Karpathy, who recently became the director of Tesla's AI and Autopilot Vision. There are many examples and it is easy to understand. -Overview of LSTM network --Details on the calculation process.

MIDI(SMF) This format expresses performance data as a sequence of chunks with pitch, volume, time information, etc. Use (part of) this sequence as LSTM input.

Process flow

  1. Parse the MIDI file to be learned and convert chunks to strings
  2. Train the model using the transformed chunk sequence
  3. Generate text data that expresses MIDI data based on the created model and a sequence of appropriate chunks. ** Randomness is added by changing the parameters used for sampling from the probability distribution each time the output is from the model. ** **
  4. Convert the output result to MIDI

result

When we tried to output elements with a low probability of occurrence at a certain frequency, a song with a slightly arranged original song was generated.

Remarks

The self-made MIDI parser is currently quite simple, and there are chunks and information that have not been processed, so if you make a little more, the quality of the output will improve.

Recommended Posts

The story of making a music generation neural network
Visualize the inner layer of a neural network
The story of making a lie news generator
The story of making a mel icon generator
Implementation of a two-layer neural network 2
Touch the object of the neural network
The story of writing a program
The story of making a question box bot with discord.py
The story of making Python an exe
The story of making an immutable mold
The story of making a standard driver for db with python.
The story of blackjack A processing (python)
The story of making a module that skips mail with python
Understand the number of input / output parameters of a convolutional neural network
The story of making a university 100 yen breakfast LINE bot with Python
The story of making a sound camera with Touch Designer and ReSpeaker
The story of making a package that speeds up the operation of Juman (Juman ++) & KNP
The story of making the Mel Icon Generator version2
The story of sys.path.append ()
The story of making a box that interconnects Pepper's AL Memory and MQTT
The story of making a web application that records extensive reading with Django
The story of making a Line Bot that tells us the schedule of competitive programming
A story that reduces the effort of operation / maintenance
A story about making Hanon-like sheet music with Python
Basics of PyTorch (2) -How to make a neural network-
A story about changing the master name of BlueZ
Implementation of a convolutional neural network using only Numpy
Zip 4 Gbyte problem is a story of the past
A story that analyzed the delivery of Nico Nama.
Implement a 3-layer neural network
The story of building Zabbix 4.4
[Apache] The story of prefork
The story of creating a VIP channel for in-house chatwork
A network diagram was created with the data of COVID-19.
The story of a Django model field disappearing from a class
Construction of a neural network that reproduces XOR by Z3
The story of creating a database using the Google Analytics API
I tried to predict the genre of music from the song title on the Recurrent Neural Network
How to easily draw the structure of a neural network on Google Colaboratory using "convnet-drawer"
A story stuck with the installation of the machine learning library JAX
The story of Python and the story of NaN
Let's summarize the basic functions of TensorFlow by creating a neural network that learns XOR gates
A story that struggled to handle the Python package of PocketSphinx
What is a Convolutional Neural Network?
I implemented a two-layer neural network
The story of creating a site that lists the release dates of books
The story of the "hole" in the file
A command to easily check the speed of the network on the console
[Pythonista] The story of making an action to copy selected text
The story of making a tool that runs on Mac and Windows at the game development site
The story of remounting the application server
[NNabla] How to remove the middle tier of a pre-built network
Generation of time series by recurrent neural network (Magenta translation ① where artificial intelligence makes art and music)
The story of making a slackbot that outputs as gif or png when you send the processing code
The story of making a tool to load an image with Python ⇒ save it as another name
A story that visualizes the present of Qiita with Qiita API + Elasticsearch + Kibana
The story of a Parking Sensor in 10 minutes with GrovePi + Starter Kit
Build a classifier with a handwriting recognition rate of 99.2% with a TensorFlow convolutional neural network
The story of having a hard time introducing OpenCV with M1 MAC
I tried how to improve the accuracy of my own Neural Network
The story of developing a web application that automatically generates catchphrases [MeCab]