1-D Convolution Forward and Backward

hard
Unit 22 · Optimizers0/1 to milestone

1-D convolutions process audio, sensor streams and sequences. Implement one with stride 1 and no padding (actually a cross-correlation, as in every deep learning library):

y[n,o,t]=b[o]+∑c∑kW[o,c,k]  x[n,c,t+k]y[n, o, t] = b[o] + \sum_{c}\sum_{k} W[o, c, k]\; x[n, c, t + k]

for x: (N, C_in, L), W: (C_out, C_in, K) and b: (C_out,), giving y: (N, C_out, L - K + 1).

Implement conv1d_forward(x, W, b) returning (y, cache), and conv1d_backward(dy, cache) returning (dx, dW, db). Then implement causal_conv1d(x, W, b), which left-pads the input with K - 1 zeros so the output has length L and position t only sees inputs ≤ t (as in WaveNet).

#cnns#backprop#sequences2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
1-D Convolution Forward and Backward · TechGradify