We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← CNNs from Scratch step 9 of 15
Medium
End-to-End
Simple CNN
Build a minimal CNN: 1D convolution + max pooling + fully connected layer.
Pipeline:
- Conv1D: slide a kernel of size K over input with stride 1, add bias. $\text{conv}[i] = \sum_{k=0}^{K-1} x[i+k] \cdot w[k] + b_{conv}$ Output length: $L_{out} = L - K + 1$
- ReLU: element-wise $\max(0, z)$
- Global Max Pool: take the max over the sequence to get a single scalar.
- FC layer: $y = \text{pool\_out} \cdot w_{fc} + b_{fc}$
Input:
-
x: 1D input of shape(L,) -
conv_w: kernel of shape(K,) -
conv_b: scalar bias -
fc_w: FC weight (scalar) -
fc_b: FC bias (scalar)
Output: A scalar prediction.
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.