#127Feature volume — a conv layer's output shapeEasyCNNComputer Vision
Feature volume — a conv layer's output shape
Background
A conv layer turns an (H, W, C_in) volume into an (H', W', F) volume: the spatial size shrinks per the convolution formula, and the depth becomes the number of filters F (each filter makes one feature map). Per spatial dim:
Problem statement
Implement conv_block_shape(H, W, kernel, stride, padding, filters) returning the output volume shape (H', W', filters).
Input
H,W— input height and width.kernel,stride,padding— conv hyperparameters.filters— number of conv filtersF.
Output
Returns a tuple (H', W', filters).
Examples
Example 1 — the lesson's first conv (16 filters)
Input: H = 32, W = 32, kernel = 3, stride = 1, padding = 0, filters = 16
Output: (30, 30, 16)
Example 2 — same padding keeps H, W
Input: H = 28, W = 28, kernel = 3, stride = 1, padding = 1, filters = 64
Output: (28, 28, 64)
Constraints
- Spatial size uses for each of H and W.
- The output depth is
filters. - Return a tuple of ints.
Notes
- Stacking blocks, depth tends to grow (more filters) while H and W shrink (stride / pooling) — the "feature volume" getting deeper and smaller as you go.
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 — 32x32x3, 16 filters (lesson conv)
- •Reference — same padding keeps spatial size
- •Sample — stride 2 downsamples, depth=filters