Notes on ML, AI, and neuroscience#

Working notes on machine learning, statistics, AI, and neuroscience, kept since 2015 and organized into a book.

Each chapter is one of the notes from csinva.io: mostly compact bullet points, equations and figures, with a short overview at the top and interactive figures where moving a slider says more than a paragraph would. The foundations come first (computer science, math, statistics), then machine learning, AI and neuroscience, and finally research overviews that collect papers on open problems.

Where to start#

A few routes through the book, each ordered so that earlier chapters set up later ones. The parts further down list every chapter.

Machine learning from the ground up

The linear algebra, probability and optimization that ML uses, then the standard methods, then why they generalize.

  1. Linear algebra
  2. Stat basics
  3. Optimization
  4. Classification
  5. Evaluation
  6. Unsupervised
  7. Deep learning
  8. Learning theory

Statistics and causal inference

From estimators and tests to regression and graphical models, then reading causal effects from data.

  1. Stat basics
  2. Testing
  3. Linear models
  4. Graphical models
  5. Causal inference (statistics)
  6. Causal inference (research overviews)

Deep learning, LLMs and interpretability

Neural networks and language models, then the research on how they work and what they learn.

  1. Deep learning
  2. NLP
  3. LLMs (artificial intelligence)
  4. Embeddings
  5. LLMs (research overviews)
  6. Interpretability

Brains and minds

How neurons signal, how the senses and movement work, and the models and cognitive science built on them.

  1. Brain basics
  2. Sensory input
  3. Vision
  4. Motor system
  5. Computational neuroscience
  6. Cognitive science
  7. Psychology

Classic AI

Search and logic, decisions under uncertainty and reinforcement learning, then the questions AI raises for society.

  1. Search and logic
  2. RL and decisions
  3. Graphical models
  4. Fairness and STS
  5. AI futures

Computer systems

The data structures and algorithms everything else assumes, then how the machine and the operating system run programs.

  1. Data structures
  2. Algorithms
  3. Architecture
  4. Operating systems
  5. Languages and parallel computing
  6. Theory of computation

How the chapters connect#

Each chapter is linked to the chapters that share the most vocabulary with it, which is a quick way to see how the topics connect. Hover over a chapter to see its neighbors, or click it to open it.

Each dot is a chapter, colored by part and linked to its three most similar chapters (tf-idf over the note text). Click a part to highlight it.

Computer science#

Data structures, algorithms, architecture and operating systems, programming languages and parallel training, information retrieval, the theory of computation, and a little quantum computing.

Data structures

Linked lists and stacks, balanced search trees, heaps and Huffman codes, hash tables, and the standard graph algorithms.

13 min · 2 interactive

Data structures
Algorithms

Big-O notation, a catalog of sorting algorithms, lower bounds for finding the min and the median, and convex hulls and Voronoi diagrams.

5 min · 2 interactive

Algorithms
Languages and parallel computing

Syntax references for python, c/c++, java and R, and the collective operations behind multi-GPU training.

12 min · 1 interactive

Languages and parallel computing
Architecture

Integers and floats in bits, assembly and calling conventions, a pipelined processor, caches, exceptions and virtual memory.

22 min · 2 interactive

Architecture
Operating systems

Processes and threads, synchronization and deadlock, CPU scheduling, paging and virtual memory, and file systems.

23 min · 1 interactive

Operating systems
Information retrieval and databases

How a search engine is put together, how retrieval differs from exact database lookup, and the main kinds of databases.

3 min

Information retrieval and databases
Theory of computation

Finite automata, context-free grammars and pushdown automata, Turing machines, undecidability, and NP-completeness.

11 min · 1 interactive

Theory of computation
Quantum computing

Qubits and amplitudes, which problems quantum computers might speed up, Maxwell’s demon, and a matrix view of probability.

3 min · 1 interactive

Quantum computing

Mathematics#

Reference chapters on calculus, linear algebra and optimization, plus real analysis, differential equations, nonlinear dynamics and signal processing.

Math basics

Handy bounds, common functions, sets and logic, proof techniques, log and trig identities, and complex numbers in polar form.

2 min · 1 interactive

Math basics
Calculus

Taylor expansions, tables of derivatives, integrals and series, and Lagrange multipliers for constrained minimization.

1 min · 1 interactive

Calculus
Linear algebra

Matrix properties, matrix calculus, vector and matrix norms, and the eigenvalue and singular value decompositions.

5 min · 3 interactive

Linear algebra
Differential equations

Recipes for ordinary differential equations, from separable and first-order linear equations to constant coefficients, variation of parameters and Laplace transforms.

1 min · 1 interactive

Differential equations
Real analysis

Completeness of the reals, sequences and series, open and compact sets, continuity, derivatives, uniform convergence and the Riemann integral.

3 min · 2 interactive

Real analysis
Optimization

Convex sets and functions, duality and the KKT conditions, descent methods, the optimizers used for neural nets, EM and branch-and-bound.

5 min · 3 interactive

Optimization
Signal processing

Sampling, filters, the Fourier transform and DFT, and wavelets, which are localized in both time and frequency.

4 min · 2 interactive

Signal processing
Nonlinear dynamics and chaos

Bifurcations, stability of fixed points, maps that period-double into chaos, conservative systems and the Lorenz equations.

3 min · 1 interactive

Nonlinear dynamics and chaos

Statistics#

Probability basics, data analysis, testing, linear models, time series, information theory, graphical models and causal inference.

Stat basics

Expectations and variances, the usual distributions, the law of large numbers and CLT, and the bias-variance trade-off.

6 min · 3 interactive

Stat basics
Data science

Sampling, clear plots, smoothing, imbalanced and missing data, feature selection, and tools and principles for reproducible analysis.

11 min · 2 interactive

Data science
Testing

Null and alternative hypotheses, p-values, type 1 and 2 errors and power, t- and F-tests, confidence intervals, and ANOVA.

3 min · 2 interactive

Testing
Linear models

Least squares and its geometry, ridge, lasso and elastic net, GLS and GLMs, and nonparametric extensions like kernel regression and GAMs.

6 min · 2 interactive

Linear models
Time series

Trend, seasonality and stationarity, AR, MA and ARMA models, autocovariance and Yule-Walker estimation, and similarity measures like DTW.

5 min · 1 interactive

Time series
Information theory

Entropy, KL divergence and mutual information, their chain rules and inequalities, and minimum description length.

6 min · 2 interactive

Information theory
Graphical models

Bayesian networks and undirected models, exact inference by elimination and message passing, sampling and variational inference, and HMMs and Kalman filters.

10 min · 2 interactive

Graphical models
Causal inference

Potential outcomes and causal graphs, randomized experiments, quasi-experiments like instruments and regression discontinuity, and effect estimation from observational data.

24 min · 3 interactive

Causal inference

Machine learning#

Classifiers and how to evaluate them, unsupervised and generative models, kernels, deep learning, computer vision, NLP, and learning theory.

Classification

Linear classifiers as regularizer plus loss, SVMs, trees and forests, naive Bayes and Gaussian classifiers, nearest neighbors, and boosting.

9 min · 3 interactive

Classification
Evaluation

Losses and risk, precision, recall and ROC curves, cross-validation, and resampling for stability.

2 min · 2 interactive

Evaluation
Unsupervised

Clustering, dimensionality reduction, deep generative models (VAEs, GANs, diffusion, flows), and self-supervised and contrastive learning.

15 min · 2 interactive

Unsupervised
Kernels

Valid kernels and their RKHS, and how the eigenvectors of a kernel matrix reveal clusters.

1 min · 2 interactive

Kernels
Deep learning

Backpropagation, the main architectures (CNNs, RNNs, GNNs), normalization layers, and training tricks.

9 min · 2 interactive

Deep learning
Computer vision

How images form, how to filter them and find features, stereo and motion, human vision, and deep networks for vision.

20 min · 2 interactive

Computer vision
NLP

NLP tasks and benchmarks, tokenization, word embeddings, n-gram language models, and parse trees.

9 min · 2 interactive

NLP
Learning theory

How many examples a learner needs, from PAC bounds and VC dimension to version spaces.

3 min · 2 interactive

Learning theory

Artificial intelligence#

Search, logic, decisions and reinforcement learning, transformers and LLMs, and the psychology, philosophy and ethics around AI.

Search and logic

Uninformed and A* search, local search, constraint satisfaction, propositional and first-order logic, planning, and rule learning.

19 min · 2 interactive

Search and logic
RL and decisions

Game trees, utility theory, the value of information, MDPs, reinforcement learning, deep RL, and RL for LLMs.

14 min · 3 interactive

RL and decisions
LLMs

The shapes inside a decoder-only transformer, KV caching, self-attention worked by hand, and a reading list of influential transformer models.

9 min · 2 interactive

LLMs
Psychology

How people explain things (Miller, Lombrozo), plus book notes on evolutionary and moral psychology, the evolution of intelligence, and therapy.

36 min · 1 interactive

Psychology
Cognitive science

How minds might form representations (nativism, empiricism, Bayesian models, deep learning), language, theory of mind, symbolic AI, and cognitive biases.

15 min · 1 interactive

Cognitive science
Philosophy

What makes something a scientific explanation (DN model, statistical relevance, causal mechanisms, unification, pragmatics), plus Deutsch, Kuhn and Durant.

10 min

Philosophy
Fairness and STS

Fairness definitions and fixes, harms of computer vision, a legal test for proxy variables, ethics and moral trade, STS, and effective altruism.

9 min · 1 interactive

Fairness and STS
AI futures

Short thoughts on AGI, then notes on Stuart Russell’s Human Compatible and the essays in Possible Minds.

11 min

AI futures

Neuroscience#

How neurons signal, how the senses, motor system and memory work, and the models and data used to study them.

Brain basics

The parts of the brain, then how a neuron makes a voltage, fires, and talks to the next neuron through synapses and transmitters.

16 min · 2 interactive

Brain basics
Sensory input

How touch, pain, sight, hearing, balance and taste get from receptors through the thalamus to cortex.

9 min · 1 interactive

Sensory input
Vision

The visual system from photoreceptors and retinal circuits to V1 and beyond, with the methods used to record it and the diseases that damage it.

22 min · 3 interactive

Vision
Motor system

From spinal reflexes up through motor cortex, basal ganglia and cerebellum, plus eye movements and the autonomic system.

9 min · 1 interactive

Motor system
Memory

A history of memory research, from Cajal’s neurons to the molecules that turn a short-term memory into a long-term one.

9 min

Memory
Development

How the nervous system builds itself, from the neural tube and morphogen gradients to axon guidance, competition, critical periods and repair.

7 min · 1 interactive

Development
Disease

Alzheimer’s and Parkinson’s, then how pathologists grade cancer from tissue slides and where deep learning fits in.

10 min · 1 interactive

Disease
Computational neuroscience

Models of neurons, neural codes and learning rules, then data-driven neuroscience, brain encoding models and neuro-inspired AI.

60 min · 5 interactive

Computational neuroscience

Research overviews#

Annotated reading lists on open research topics, from LLMs, embeddings and interpretability to uncertainty, causal inference and deep learning theory. Most papers come with a short note on what they do.

Interesting science

A grab bag of surprising results from neuroscience, biology, statistics and machine learning.

1 min

Interesting science
ML in medicine

Clinical datasets, bias in clinical decision instruments, and how doctors reason about and use models.

8 min

ML in medicine
Embeddings

Training embedding models, contrastive losses, approximate nearest-neighbor search, RAG and interpretable embeddings.

27 min · 1 interactive

Embeddings
LLMs

Prompting, architectures and reasoning, mechanistic interpretability, and LLMs that explain data and do science.

102 min · 1 interactive

LLMs
Transfer learning

Training models that hold up when the test data shift, from domain adaptation and test-time training to adversarial attacks.

6 min · 1 interactive

Transfer learning
Uncertainty

Calibration, outlier detection, ensembles, Bayesian neural nets and conformal prediction.

5 min · 2 interactive

Uncertainty
Interpretability

Evaluating interpretations, transparent models like rules, trees and GAMs, and post-hoc explanations of fitted models.

66 min · 1 interactive

Interpretability
Generalization

Generalization error as risk minus empirical risk, bounds from uniform stability, and a lower bound for trees on additive data.

1 min

Generalization
Disentanglement

Disentangled VAE losses and their variants, GAN latent spaces edited during or after training, weak supervision, and how disentanglement is measured.

12 min · 1 interactive

Disentanglement
Causal inference

Classic causal studies, mediation, heterogeneous effects, causal discovery, invariant prediction, and neural nets for treatment effects.

20 min · 1 interactive

Causal inference
Omics

Predicting RNA and protein structure from sequence, from dynamic programming to AlphaFold, plus engineered viruses as treatment.

6 min

Omics
Scattering transform

Fixed wavelet filters in place of learned ones, from Mallat’s scattering transform to hybrid networks and adaptive wavelets.

3 min

Scattering transform
Complexity

What complexity means for a model, from philosophy and Kolmogorov complexity to VC dimension, double descent and minimum description length.

8 min · 1 interactive

Complexity
Deep learning theory

Why overparameterized nets generalize, seen through implicit regularization, kernels, expressiveness, statistical physics and empirical studies.

15 min · 1 interactive

Deep learning theory