+ Part III · Learning from data
How an AI model is built and scored.
In 2016 a team at Google trained a neural network to grade photographs of the retina for diabetic retinopathy without writing a single rule about what the disease looks like: no instruction to look for small hemorrhages, no threshold for the size of a lesion. Every rule the network applied came instead from 128,175 images that ophthalmologists had already graded. A program built that way can still be tested, but only by comparing its answers with right answers on data it has not seen. Every step of that comparison involves choices that decide what the result means. The four chapters of this part follow those choices: what a model is, how the data that builds it is kept apart from the data that judges it, what the right answers are and who decided them, and how a score becomes a decision with a measurable error.
Rules nobody wrote.
+ The questionWhat is a machine-learning model, and how is building one different from writing code?
Twenty-five million adjustable numbers
ResNet-50 is one of the most widely used neural networks for analyzing images. The version published with the PyTorch software library has about 25.6 million adjustable numbers. Each is a parameter: most are weights that multiply values inside the network before they are passed on, and the rest are offsets added along the way. A photograph goes in as a grid of pixel intensities and passes through some fifty layers, each of which combines the values from the layer before using its weights, so that a score comes out at the end: for example, the network's estimate that the image shows a particular disease. If the weights change, the same photograph produces a different score.
A machine-learning model is that whole arrangement: a fixed structure, chosen by engineers, with its parameters set from data rather than by hand. The structure is code like any other, written, reviewed and tested. The parameters are not written at all. They are found by training. The model scores a batch of examples whose right answers are known, the training code computes a measure of how wrong the scores were, called the loss, and the code then nudges every parameter slightly in the direction that would have made the loss smaller. Repeated over millions of batches, the nudges settle into values that make the model's scores match the known answers well.
Google's system of 2016 was trained this way, on 128,175 retinal images that a panel of 54 US ophthalmologists and senior residents had graded three to seven times each. The system was an ensemble of ten networks of a design called Inception-v3; an ensemble is a set of models whose scores are combined into one. Its authors describe each of the ten networks as having about 22 million parameters.
Fitting, and fitting too well
Training finds parameters that fit the examples. Whether they fit anything else is a separate question, and the Google system shows why: each of its networks had more parameters than there were images to fit. A model with that much freedom can, in principle, memorize its training set, giving the right answer for every image it has seen and an arbitrary one for any image it has not. Engineers limit memorization in four ways: by the choice of structure, by starting from parameters already trained on more than a million ordinary photographs, by penalties that keep weights small, and by stopping training before the fit becomes too close. None of these guarantees that the model will work on new images; only a test on new images can show whether it does.
Take ten points along a straight line, y equals 2x for x from 0 to 9, each moved up or down by a small, fixed amount of noise between about −1.4 and +1.3. A straight line has two parameters. Fitted to the ten points, it misses them by 0.93 on average. The average here is the root mean square: each miss is squared, the squares are averaged, and the square root of that average is taken, so that large misses count for more. A polynomial with ten parameters, a curve built from x and its powers up to x to the ninth, can pass through every point exactly, so its error on the training points is zero. Now test both on nine new points taken halfway between the old ones, from the same line with fresh noise. The straight line misses them by 0.78 on average. The polynomial misses them by 1.67, more than twice as much, because between the training points it bends to follow the noise. The model with the better training score is the worse model.
The omics guide in this library describes the same problem in another form. A molecular signature is a pattern across many molecular measurements that is used to classify patients. A signature discovered from many more measurements than patients fits its discovery data almost perfectly and fails on the next cohort; only a locked signature tested on independent samples shows whether it is real. An image network differs in scale, not in principle. Its score on the training data describes the past; its value lies in its predictions about data it has not seen.
The data is part of the design
Because the parameters come from the examples, any regularity the examples contain is a candidate for the model to learn. Some regularities are signs of the disease. Others are accidents of how the data was collected: which hospital an image came from, which camera took it, what text was stamped in its corner. A model has no way to tell a sign of disease from a sign of the clinic where diseased patients were photographed, unless the data contains cases that separate the two. Chapter 11 shows a network that learned, in part, to recognize the hospital.
The fact that shapes this guide, that software does not wear out, extends to AI. A conventional program's faults are built into its code; a model's faults can also be built into its data, through what the data contains, what it lacks and how its labels were assigned. A label is the right answer recorded for an example. It is unrelated to a device's labeling, the label and accompanying written material of Chapter 1. The device is the code, the parameters and the data that set them, together with the processing that turns a raw image into the grid of numbers the model expects. Changing any of them changes the device.
Reviewers can read the code of a model's structure, but they cannot read its parameters as rules, and no list of the features a network relies on is complete. Evidence about what a model does therefore comes from its behavior on carefully chosen data. The quality of that data, not how well the code is written, sets the limit on what can be claimed.
Locked and learning models
A model whose parameters are fixed after training is locked: the same input always gives the same output, and the model can be verified like any other software. The paper that reports the 2017 trial states that IDx-DR's analysis was locked before the trial began. A model that keeps adjusting its parameters from new data in the field is continuously learning: its behavior on Tuesday may differ from Monday's, and the evidence gathered before release describes a model that no longer exists.
In 2019 the FDA wrote that the AI devices it had cleared or approved had typically "only included algorithms that are 'locked' prior to marketing." Updates happen, but as new versions: retrained, tested and released through the change controls of Chapter 21. One of the earliest authorized plans for changing an AI device belongs to a program that guides cardiac ultrasound. When the maker modified that plan through a 510(k) in 2020, the public summary stated that all algorithm modifications would be "trained, tuned, and locked prior to release", and the plan excluded continuously learning algorithms. A draft EU guideline on AI in the manufacture of medicines goes further. It was published for consultation in July 2025 and was still a draft as of October 2026. It states that dynamic models, which keep adapting to new data in use, should not be used in critical applications at all. How a model may change after authorization is the second half of this guide's central question, and Part V answers it.
Put the model's structure, its trained parameters, the preprocessing code and an identifier of the exact training data under configuration management as one released item, with a version that changes whenever any of them does. Record the data's origin, size and labeling method alongside, so that a later reviewer can tell which data produced which version of the model.
- A machine-learning model is a fixed structure whose millions of parameters are set by training on examples with known answers.
- A model can fit its training data closely and still predict poorly; only a test on data it has not seen shows whether it generalizes.
- The training data is part of the design, so a model can learn accidents of data collection as readily as signs of disease.
- Locked models give the same output for the same input; in 2019 the FDA wrote that the AI devices it had authorized were typically locked, and such devices change only through new, tested versions.
Let's Talk