We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← Classifiers from Scratch step 1 of 5
Easy
End-to-End
Binary Classifier
Build a binary classifier that outputs a probability using sigmoid.
The forward pass computes:
- Linear: $z = x \cdot W + b$
- Sigmoid: $p = \sigma(z) = \frac{1}{1 + e^{-z}}$
Also compute the Binary Cross-Entropy (BCE) loss: $$\text{BCE} = -\frac{1}{N}\sum [y \log(p) + (1-y)\log(1-p)]$$
Input:
-
x: input tensor of shape(batch, features) -
W: weight matrix of shape(features, 1) -
b: bias scalar of shape(1,) -
y: target labels of shape(batch, 1)with values 0 or 1
Output: A dict with “prediction” (shape (batch, 1)) and “loss” (scalar).
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.