Uploaded December 2023 | Updated September 2026, 2 weeks ago
Learn how to implement a transformer architecture in TensorFlow to generate melodies end to end. You’ll learn about melody encoding, dataset preprocessing, model building, training, and inference.
Get code:
github.com/musikalkemist/generativemusicaicourse/tree/main/19.%20Melody%20generation%20with%20transformers/Code
Get the lecture slides:
github.com/musikalkemist/generativemusicaicourse/blob/main/19.%20Melody%20generation%20with%20transformers/Slides/19.%20Melody%20generation%20with%20transformers.pdf
Website of the Generative Music AI Workshop in Barcelona:
https://www.upf.edu/web/mtg/generative-music-ai-workshop
Sign up to The Sound of AI Slack Community to join the discussion:
valeriovelardo.com/the-sound-of-ai-community
======================================
Interested in music AI consulting?
thesoundofai.com/consulting.html
Interested in music AI recruitment?
thesoundofai.com/recruitment.html
Become a Python ninja with my Advanced Python Programming course:
the-sound-of-ai-academy.teachable.com/p/advanced-python-programming
Connect with Valerio on LinkedIn:
linkedin.com/in/valeriovelardo
Follow Valerio on Twitter:
twitter.com/musikalkemist
======================================
Content
0:00 Intro
0:48 What we'll build
7:13 Code overview
7:29 Melody dataset
9:03 MelodyPreprocessor
19:57 Transformer
28:12 Encoder
36:34 EncoderLayer
40:28 Decoder
43:25 DecoderLayer
48:30 MelodyGenerator
54:54 Train script
1:06:19 Runing the train script
1:08:48 Experimenting with the code
1:11:25
What's up next?
Learn how to implement a transformer architecture in TensorFlow to generate melodies end to end. You’ll learn about melody encoding, dataset preprocessing, model building, training, and inference.
Get code:
github.com/musikalkemist/generativemusicaicourse/tree/main/19.%20Melody%20generation%20with%20transformers/Code
Get the lecture slides:
github.com/musikalkemist/generativemusicaicourse/blob/main/19.%20Melody%20generation%20with%20transformers/Slides/19.%20Melody%20generation%20with%20transformers.pdf
Website of the Generative Music AI Workshop in Barcelona:
https://www.upf.edu/web/mtg/generative-music-ai-workshop
Sign up to The Sound of AI Slack Community to join the discussion:
valeriovelardo.com/the-sound-of-ai-community
======================================
Interested in music AI consulting?
thesoundofai.com/consulting.html
Interested in music AI recruitment?
thesoundofai.com/recruitment.html
Become a Python ninja with my Advanced Python Programming course:
the-sound-of-ai-academy.teachable.com/p/advanced-python-programming
Connect with Valerio on LinkedIn:
linkedin.com/in/valeriovelardo
Follow Valerio on Twitter:
twitter.com/musikalkemist
======================================
Content
0:00 Intro
0:48 What we'll build
7:13 Code overview
7:29 Melody dataset
9:03 MelodyPreprocessor
19:57 Transformer
28:12 Encoder
36:34 EncoderLayer
40:28 Decoder
43:25 DecoderLayer
48:30 MelodyGenerator
54:54 Train script
1:06:19 Runing the train script
1:08:48 Experimenting with the code
1:11:25
What's up next?










