Model as a Function

A function maps inputs to outputs.

A model does the same thing, but with stored parameters:

y_hat = f(x; theta)

Read this as:

prediction = model(input; parameters)

The semicolon is a convention. It separates the input x from the parameters theta.

The input is what the model is asked about. The parameters define which function the model currently represents.

Same input, different parameters

Let:

f(x; w, b) = wx + b

For the same input x = 2:

w = 3, b = 1   -> f(2) = 7
w = 1, b = 5   -> f(2) = 7
w = 4, b = 0   -> f(2) = 8

Changing parameters changes the function.

Training is the process of finding parameters that make the model's outputs useful for the task.

DL-C02-T02-001Exercise: Same input, different function

Let f(x; w, b) = wx + b. For x = 5, w = 2, and b = 3, what is f(x; w, b)?

Compute it first, then check your number.

HintUse the current parameters

The parameters tell you which function to compute.

SolutionWork it out

f(5; 2, 3) = 2 x 5 + 3 = 13.

DL-C02-T02-002Exercise: Which part defines the current model

In f(x; theta), enter 1 if theta represents parameters, or 0 if it represents the input data.

Compute it first, then check your number.

HintRead the notation

x is the input. theta is the stored state of the model.

SolutionWork it out

theta represents the model parameters. Changing theta changes which function the model computes.