#176Neuron — the linear score z = wᵀx + bEasyNeural Networks
Neuron — the linear score z = wᵀx + b
Background
Every neuron starts the same way: an affine map of the inputs.
This single number is the neuron's pre-activation score. Linear regression, logistic regression, and the perceptron all compute this same — they differ only in what they do after it. Getting right is the foundation of the whole course.
Problem statement
Implement neuron_score(x, w, b) returning the scalar for one input.
Input
x— array-like feature vector of length .w— array-like weight vector of length .b—float, the bias.
Output
Returns a Python float: the linear score .
Examples
Example 1
Input: x = [2, 3], w = [2, 3], b = -5
Output: 8.0
Explanation: .
Example 2 — bias shifts the score
Input: x = [0, 0], w = [1, 1], b = 0.7
Output: 0.7
Explanation: with zero inputs only the bias survives, which is exactly why lets the boundary avoid the origin.
Constraints
- Compute the dot product and add
b. - Return a plain
float.
Notes
- The bias shifts up or down independently of the inputs — that is what lets a neuron's decision boundary sit anywhere, not just through the origin.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •example score
- •reference bias only
- •sample negative score