Implement a compact numerical VGG forward pass. Execute the supplied convolution and pooling configuration, flatten the resulting features, apply two affine layers with ReLU, and apply the final affine classifier without activation. The classifier dictionary contains W1, b1, W2, b2, W3, and b3. Return raw class logits as a float64 NumPy array.
Examples
Input: x = [[[[1],[2]],[[3],[4]]]], config = [1,"M"], kernels = [[[[[1]]]]], biases = [[0]], classifier = {"W1":[[0.5]],"b1":[0],"W2":[[2]],"b2":[-1],"W3":[[0.3,-0.2]],"b3":[0.1,0]}
Output: [[1,-0.6]]
Explanation: The configuration produces spatial features that are flattened and passed through the complete classifier.
Input: x = [[[[1,-1]]]], config = [2], kernels = [[[[[1,0],[0.5,1]]]]], biases = [[0,0.1]], classifier = {"W1":[[1],[0.5]],"b1":[0],"W2":[[1]],"b2":[0.2],"W3":[[1]],"b3":[-0.1]}
Output: [[0.6]]
Input: x = [[[[1]]],[[[-1]]]], config = [1], kernels = [[[[[2]]]]], biases = [[0.5]], classifier = {"W1":[[1,-1]],"b1":[0,0.2],"W2":[[1],[0.5]],"b2":[0],"W3":[[1,-1]],"b3":[0.1,0.2]}
Output: [[2.6,-2.3],[0.2,0.1]]
Hint 1
Finish all config entries before flattening.
Hint 2
Use the next kernel only for an integer config entry.
Hint 3
Do not apply ReLU after the final classifier projection.
Requirements
- Use NumPy and every supplied parameter.
- Execute config entries in order.
- Apply ReLU after convolutions and the first two classifier layers.
- Apply pooling only for M entries.
- Return float64 raw logits.
Constraints
- x uses NHWC layout and dtype float64.
- config, kernels, and biases satisfy the feature-extractor contract.
- classifier contains exactly W1, b1, W2, b2, W3, and b3 with compatible float64 shapes.
- Spatial dimensions are even whenever pooling occurs.
All steps in VGG
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: object
Complete VGG Network
Implement a compact numerical VGG forward pass. Execute the supplied convolution and pooling configuration, flatten the resulting features, apply two affine layers with ReLU, and apply the final affine classifier without activation. The classifier dictionary contains W1, b1, W2, b2, W3, and b3. Return raw class logits as a float64 NumPy array.
Examples
Input: x = [[[[1],[2]],[[3],[4]]]], config = [1,"M"], kernels = [[[[[1]]]]], biases = [[0]], classifier = {"W1":[[0.5]],"b1":[0],"W2":[[2]],"b2":[-1],"W3":[[0.3,-0.2]],"b3":[0.1,0]}
Output: [[1,-0.6]]
Explanation: The configuration produces spatial features that are flattened and passed through the complete classifier.
Input: x = [[[[1,-1]]]], config = [2], kernels = [[[[[1,0],[0.5,1]]]]], biases = [[0,0.1]], classifier = {"W1":[[1],[0.5]],"b1":[0],"W2":[[1]],"b2":[0.2],"W3":[[1]],"b3":[-0.1]}
Output: [[0.6]]
Input: x = [[[[1]]],[[[-1]]]], config = [1], kernels = [[[[[2]]]]], biases = [[0.5]], classifier = {"W1":[[1,-1]],"b1":[0,0.2],"W2":[[1],[0.5]],"b2":[0],"W3":[[1,-1]],"b3":[0.1,0.2]}
Output: [[2.6,-2.3],[0.2,0.1]]
Hint 1
Finish all config entries before flattening.
Hint 2
Use the next kernel only for an integer config entry.
Hint 3
Do not apply ReLU after the final classifier projection.
Requirements
- Use NumPy and every supplied parameter.
- Execute config entries in order.
- Apply ReLU after convolutions and the first two classifier layers.
- Apply pooling only for M entries.
- Return float64 raw logits.
Constraints
- x uses NHWC layout and dtype float64.
- config, kernels, and biases satisfy the feature-extractor contract.
- classifier contains exactly W1, b1, W2, b2, W3, and b3 with compatible float64 shapes.
- Spatial dimensions are even whenever pooling occurs.
All steps in VGG
Accepts: array
Accepts: array
Accepts: array
Accepts: array
Accepts: object