Neural networks surround us, in the form of large language models, speech transcription systems, molecular discovery algorithms, robotics, and much more. Stripped of anything else, neural networks are compositions of differentiable primitives, and studying them means learning how to program and how to interact with these models, a particular example of what is called differentiable programming.
This primer is an introduction to this fascinating field imagined for someone, like Alice, who has just ventured into this strange differentiable wonderland. I overview the basics of optimizing a function via automatic differentiation, and a selection of the most common designs for handling sequences, graphs, texts, and audios. The focus is on a intuitive, self-contained introduction to the most important design techniques, including convolutional, attentional, and recurrent blocks, hoping to bridge the gap between theory and code (PyTorch and JAX) and leaving the reader capable of understanding some of the most advanced models out there, such as large language models (LLMs) and multimodal architectures.
The book is supplemented by a companion website where I will publish additional chapters and coding exercises ( The book is self-published to keep the price as low as possible, feedback on possible imprecisions is welcomed and rewarded by a (much Italian) coffee!
About the author: Simone Scardapane is a researcher at Sapienza University of Rome, where he teaches neural networks and machine learning. In his free time, he (endlessly) talks about machine learning at the intersection of the no-profit, academic, and industrial worlds.
Table of contents:
Chapter 1: Foreword and introductionChapter 2: Mathematical preliminariesChapter 3: Datasets and lossesChapter 4: Linear modelsChapter 5: Fully-connected layersChapter 6: Automatic differentiationChapter 7: Convolutional layersChapter 8: Convolutions beyond imagesChapter 9: Scaling up the modelsChapter 10: Transformer modelsChapter 11: Transformers in practiceChapter 12: Graph layersChapter 13: Recurrent layersAppendix Probability theoryAppendix Universal approximation in 1D
This was an excellent primer on connectionist models, ranging from simple regression to recent developments in transformers and LSTMs. Accessible yet fairly rigorous, I found it very useful to bring me up to speed with the essentials of modern AI.
Even for readers already familiar with the topics covered, this book is an excellent resource for teaching. It presents all concepts with clarity, using clear and simple visual and code examples to support understanding. The text strikes a strong balance, explaining technical aspects with sufficient depth while remaining accessible to its intended audience: readers with some background in linear algebra and calculus who are beginning their journey into deep learning. It's quite approachable, and I will certainly recommend it to new students and researchers joining our lab.
The first part of the book can feel a bit slow, but the pace improves significantly around the 40% mark. The chapter on graphs could benefit from more practical examples and visual aids (which are heavily present in past chapters). Also, it spends a considerable amount of time on graph theory before introducing (graph) convolutions, which might discourage newcomers to the topic from continuing further.
It was a great read overall, and it felt entertaining and relaxing at the same time. I wish I had come across this resource when I started working with DL models!!
“a book that gets me hands-on as fast as possible while teaching the theory.
That's why I recommend this amazing book by Simone Scardapane.
More than 300 pages of high-quality explanations of linear layers, convolutions, transformers, recurrent networks, and auto-grad along with PyTorch and JAX code.” — umar jamil (LinkedIn)