Problems
Loading...
Step 6 of 6
Full ResNet Assembly
Hard

Assemble a small matrix-based ResNet classifier from an initial projection, one identity block, one projection block, and a final linear classifier. Matrix multiplication replaces spatial convolution to keep the task focused on residual composition.

The first block uses x as its shortcut. The second block uses Ws_b2 because its output width changes. Each block applies ReLU after its first transformation and after residual addition. Return the final class logits as a nested list rounded to four decimal places.

Loading visualization...

Examples

Input: x = [[1.0, 0.5]], conv1 = [[0.5, -0.3], [0.2, 0.8]], W1_b1 = [[0.4, 0.1], [-0.2, 0.6]], W2_b1 = [[0.3, -0.5], [0.7, 0.2]], W1_b2 = [[0.5, -0.1, 0.3], [0.2, 0.4, -0.6]], W2_b2 = [[0.3, 0.1, -0.2], [-0.4, 0.5, 0.3], [0.1, -0.3, 0.6]], Ws_b2 = [[0.6, -0.2, 0.4], [-0.1, 0.3, 0.5]], fc = [[-0.5, 0.3], [0.2, -0.4], [0.7, 0.1]]

Output: [[-0.0388, 0.2112]]

Explanation: Input (1x2) flows through conv1+ReLU, then block 1 (identity skip, same dims), block 2 (projection skip via Ws_b2 for dim change 2->3), and finally fc for 2 class logits.

Input: x = [[0.3, -0.5], [0.8, 0.2]], conv1 = [[0.6, 0.1], [-0.4, 0.5]], W1_b1 = [[0.3, -0.2], [0.5, 0.4]], W2_b1 = [[-0.1, 0.7], [0.3, -0.3]], W1_b2 = [[0.2, 0.6, -0.3], [-0.5, 0.1, 0.4]], W2_b2 = [[0.4, -0.2, 0.1], [0.3, 0.5, -0.6], [-0.1, 0.2, 0.3]], Ws_b2 = [[-0.3, 0.4, 0.2], [0.5, -0.1, 0.6]], fc = [[0.3, -0.2], [-0.5, 0.4], [0.1, 0.6]]

Output: [[-0.1202, 0.0966], [-0.0762, 0.1484]]

Input: x = [[0.0, 0.0]], conv1 = [[0.5, -0.3], [0.2, 0.8]], W1_b1 = [[0.4, 0.1], [-0.2, 0.6]], W2_b1 = [[0.3, -0.5], [0.7, 0.2]], W1_b2 = [[0.5, -0.1, 0.3], [0.2, 0.4, -0.6]], W2_b2 = [[0.3, 0.1, -0.2], [-0.4, 0.5, 0.3], [0.1, -0.3, 0.6]], Ws_b2 = [[0.6, -0.2, 0.4], [-0.1, 0.3, 0.5]], fc = [[-0.5, 0.3], [0.2, -0.4], [0.7, 0.1]]

Output: [[0.0, 0.0]]

Hint 1

For each block, save the shortcut before evaluating the main path.

Hint 2

Use the raw block input for block one and x @ Ws_b2 for block two.

Hint 3

The classifier receives the activated output of block two.

Requirements

  • Convert every numeric input to a NumPy float64 array.
  • Apply the initial projection and ReLU.
  • Execute the identity block before the projection block.
  • Apply fc after the final residual block without a softmax.
  • Round returned logits to four decimal places.

Constraints

  • All arrays are rank 2 with compatible matrix dimensions.
  • Ws_b2 maps the first block width to the second block width.
  • fc maps final features to class logits.
  • Valid inputs are guaranteed.