A data representation is a form of information a model can use. An image, for example, must be encoded as numbers before a neural network can process it. The network then transforms those numbers toward an output, such as a class label. In PyTorch, tensors hold the input, intermediate, and output data. section 3.1 section 3.0
Intermediate representations are collections of floating-point numbers learned for a task. An early stage of image recognition might respond to edges or textures; a deeper stage might capture ears or eyes. Each stage’s representation depends on its input and the preceding layer’s weights. section 3.1
This differs from handcrafting features. To distinguish handwritten 1s from 0s, a person might design edge-direction filters or count enclosed holes. A deep-learning model instead refines useful features from examples and target labels, reducing—but not eliminating—the need for manual feature engineering. section 1.2
Flattening an image into features
A 32 × 32 image with three color values per pixel can be flattened into 3,072 input features. A fully connected classifier can transform those values into 512 hidden features and then two output features for two classes. Flattening makes the image usable as a vector, but this model does not inherently know which pixels were neighbors. section 7.2.2
# In[6]:
import torch.nn as nn
n_out = 2
model = nn.Sequential(
nn.Linear(
3072, #1
512, #2
),
nn.Tanh(),
nn.Linear(
512,
n_out, #3
)
)
The PyTorch listing makes that representation path concrete: nn.Linear maps 3,072 inputs to 512 hidden features, nn.Tanh adds a nonlinearity, and a second nn.Linear produces two outputs. section 7.2.2



