Explore Library
Code QuizIntermediate

Flatten Feature Maps for Classifier

Spot the reshape bug that mixes up the batch dimension before the dense head.

Codepython
import torch

def flatten_features(x):
    # x has shape (N, C, H, W)
    N, C, H, W = x.shape
    # flatten each sample into a vector
    return x.view(-1)

What is the bug in this flatten function?