A regression model predicts a continuous value rather than a class label. A linear prediction rule computes that value from weighted input features plus a bias: prediction = matmul(inputs, W) + b. The bias makes this an affine transformation; calling it a linear model is common shorthand. section 4.3 section 3.3.2
Start with two features
For an input point [x, y], two weights and one bias give prediction = w1 × x + w2 × y + b. A worked TensorFlow classifier trains this same rule on two blobs of points labeled 0 and 1, then thresholds its predictions at 0.5. That demonstrates the linear calculation, but it is a classification example—not a worked linear regression model for continuous targets. section 3.3.2 section 4.3
Listing 3.18 The forward pass function
def model(inputs, W, b): return tf.matmul(inputs, W) + b
The forward pass shows the complete weighted-input-plus-bias calculation in TensorFlow. section 3.3.2
To fit the worked classifier, compute mean squared error between predictions and targets, obtain gradients for W and b with GradientTape, and update both variables. The training loop runs for 40 steps. This shows how to train the linear rule from scratch, though its targets remain class labels. section 3.3.2
For house-price regression, a small neural network instead ends with a single Dense unit and no activation. Leaving that output unconstrained lets it predict values outside the 0–1 range imposed by a sigmoid. Its two preceding ReLU layers mean the whole network is not a standalone linear regression model. section 4.3.3
Practical checks for continuous-value prediction:
- Use mean squared error as a common training loss and mean absolute error to report the typical size of prediction errors; classification accuracy does not apply. section 4.3.3 section 4.3.6
- Scale input features independently when their ranges differ. With little data, prefer a small model and use K-fold validation to evaluate it more reliably. section 4.3.6





















