Math for AI course · Lesson 1 of 180
Variables, Values, and the Three Roles Inside an AI Model
Learn to read model equations by separating variable names from their current values, then trace inputs, parameters, and outputs through a tiny scoring model.
An AI model can contain millions or billions of stored numbers, receive a new set of numbers for every request, and produce yet another set of numbers as its answer. The first skill needed to read the mathematics is surprisingly small: learn to distinguish a name from the value currently attached to that name.
By the end of this lesson, you will be able to read a short model equation, identify its inputs, parameters, and outputs, substitute their values, and explain which quantities can change for different reasons.
The Mathematics for Machine Learning book begins by treating mathematics as a precise language for expressing machine learning ideas. Variables are part of that language. They let us describe one rule that works for many examples instead of writing a separate calculation for every example.
A name can outlive its current value
Suppose a tiny model gives an item a score:
The four letters are variables. Each is a name with a role:
- is the input feature supplied for the current item;
- is a weight controlling how strongly the feature affects the score;
- is a bias shifting every score by the same amount; and
- is the model’s output score.
For one item, the current values might be
Substitution replaces the names with these values for this calculation:
The value of is now . The symbol has not permanently become ; another input or another set of model parameters can produce a different value.
The intermediate product is 4.50. The names x, w, b, and s do not change when their current values change.
The interactive model exposes an important separation. Moving the control changes the example presented to the model. Moving or changes the model itself. Both actions change , but for different reasons.
Inputs, parameters, and outputs are different jobs
In machine learning, variables are often grouped by how their values are obtained.
| Role | Where its value comes from | When it normally changes | Tiny-model symbol |
|---|---|---|---|
| Input | The current data example | Between examples or requests | |
| Parameter | Values learned during training | When the optimizer updates the model | , |
| Output | The model’s calculation | Whenever inputs or parameters change |
This distinction prevents a common reading error. If you see
the subscript says that and belong to example . The same parameters and are reused. For three inputs, a single model can produce three scores:
| Example | Input | Calculation | Output |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 |
The row changes because the example changes. The rule remains the same.
Training changes parameters, not the meaning of the symbols
Before training, a model might have and . After seeing data, an optimizer might update them to and . The symbols still name the same roles, but their stored values have changed.
This is the simplest view of training:
- choose current parameter values;
- calculate outputs for some inputs;
- measure the model’s error;
- update the parameter values; and
- repeat.
Later lessons will make every step precise. For now, notice why variables are essential. The expression describes the calculation before training, during training, and after training. Only the assigned values record the model’s current state.
In code, the same separation appears in function arguments and stored values:
def score(x, weight, bias):
return weight * x + bias
weight = 1.5
bias = -1.0
first_score = score(x=1.0, weight=weight, bias=bias)
second_score = score(x=3.0, weight=weight, bias=bias)
x, weight, bias, and the returned score are names. The numbers bound to
them are values. Python names and mathematical variables are not identical in
every technical detail, but the comparison is useful: both let us express a
general operation and then evaluate it with a particular state.
A boundary: a letter does not reveal its role by itself
There is no universal rule saying must be an input or must be a weight. Authors choose notation and should define it. In another equation, might be a parameter to optimize, or might be observed data.
Another boundary is type. A variable need not hold a single real number. It can name a list, matrix, image, token sequence, probability distribution, or even a function. The name-versus-value distinction still applies. Upcoming lessons will give precise language for those richer objects.
Check your understanding
Question 1
In s = wx + b, which symbols are parameters if x is supplied by the current request?
Show the step-by-step solution
The request supplies , so is the input. The learned or stored quantities are and , making them the parameters. The equation calculates , so is the output.
The classification is therefore:
Question 2
Calculate the score when x = 4, w = -0.5, and b = 3. Show every substitution step.
Show the step-by-step solution
Start with the model rule:
Substitute the three current values:
The output variable therefore has the value for this model state and this input.
Question 3
The input changes from x = 2 to x = 5 while w and b stay fixed. Did the model change? Explain.
Show the step-by-step solution
No. The parameters defining the model rule stayed fixed, so the model did not change. A different example was evaluated.
The output will normally change because appears in , but output change alone does not tell us whether the model changed. We must ask which underlying value changed: an input value or a parameter value.
Question 4
A training step changes w from 1.5 to 1.4. What stayed constant, and what changed?
Show the step-by-step solution
The symbol and its role as a model weight stayed constant. Its assigned value changed from to .
If and are held fixed, the output change is
This also shows that the effect of the parameter update depends on the current input value.
Question 5
Why is it unsafe to assume that a symbol named x is always an input?
Show the step-by-step solution
Mathematical symbols acquire meaning from their definitions, not from the letter itself. Many authors use for an input, but another problem can define as a parameter, an unknown solution, or a random variable.
A safe reading process is:
- locate the sentence defining the symbol;
- record its allowed type or set;
- identify whether it is observed, chosen, learned, or calculated; and
- use that contract consistently in the following equations.