Join Our 5-Week ML/AI Engineer Interview Bootcamp ๐ led by ML Tech Leads at FAANGs
Implement the forward pass of a binary perceptron, which maps an input feature vector to a predicted class using a weighted sum and a step activation. This checks your understanding of basic neural network computation in deep learning fundamentals.
Implement the function
Rules:
1 if z >= 0, otherwise return 0.Output:
| Argument | Type |
|---|---|
| b | float |
| w | np.ndarray |
| x | np.ndarray |
| Return Name | Type |
|---|---|
| value | int |
x and w must have equal length
Use only Python/NumPy; no ML frameworks
Return int label 0 or 1
Start by computing the dot product between w and x: multiply each wi * xi and sum them.
After the dot product, add the bias: z = (sum of wi*xi) + b.
Apply the step activation exactly as specified: return 1 if z >= 0, else 0 (note the >=).