AlexNet is a model that trains a convolutional neural network of 5 convolutional layers and 3 fully connected layers on 1.2 million images using two GPUs. It was published in 2012 by Krizhevsky, Sutskever, and Hinton at the University of Toronto and won the image recognition competition ILSVRC-2012 by a wide margin over second place. It is called AlexNet after the first author of the paper.
Until then, the mainstream approach to image recognition was to extract hand-designed features (such as SIFT) and feed them to a classifier. CNNs were known to have a structure well suited to images, but applying them at scale to large images was computationally too expensive. AlexNet overcame this barrier because two things came together.
Large data: the ILSVRC data from ImageNet (1000 classes, about 1.2 million training images)
Fast computation: a convolution implementation optimized for GPUs (two GTX 580s, 3GB each)
The main results of the paper are as follows.
On the ILSVRC-2010 test data, it achieved a top-1 error rate of 37.5% and a top-5 error rate of 17.0%. The best results during the competition were 47.1% and 28.2%.
At ILSVRC-2012, an ensemble of 7 CNNs achieved a top-5 error rate of 15.3%, far ahead of the second-place 26.2%.
It has about 60 million parameters and about 650,000 neurons.
The combination of ReLU for faster training with dropout and data augmentation for suppressing overfitting became the standard recipe of deep learning afterwards. Triggered by AlexNet's success, image recognition research came to center on deep CNNs.
Architecture
AlexNet is a network with 8 weighted layers (5 convolutional + 3 fully connected). The output of the last fully connected layer is passed through a 1000-class softmax function to produce class probabilities. The left side of the figure at the top of the article shows the overall flow, and the right side shows how the network is split across two GPUs.
An image flows through the network in the following order (the input is a 224×224×3 image).
Conv1: applies 96 kernels of size 11×11×3 with stride 4.
Applies local response normalization (explained below) and reduces the height and width with max pooling.
Conv2: applies 256 kernels of size 5×5×48, followed by local response normalization and max pooling.
Conv3–5: stacks 3×3 kernels, 384, 384, and 256 of them, with no pooling or normalization in between.
After max pooling, the output passes through two fully connected layers of 4096 neurons, and finally a fully connected layer of 1000 neurons and a softmax function produce class probabilities.
ReLU is applied to the output of every convolutional and fully connected layer. The output shape of each layer is as follows (height × width × channels, from Figure 2 of the paper).
Layer
Kernels
Output shape
Conv1
11×11×3, 96 kernels, stride 4
55×55×96
Max pooling
3×3, stride 2
27×27×96
Conv2
5×5×48, 256 kernels
27×27×256
Max pooling
3×3, stride 2
13×13×256
Conv3
3×3×256, 384 kernels
13×13×384
Conv4
3×3×192, 384 kernels
13×13×384
Conv5
3×3×192, 256 kernels
13×13×256
Max pooling
3×3, stride 2
6×6×256
Fully connected ×2
—
4096
Fully connected
—
1000
With a 224×224 input as stated in the paper, the output of the 11×11, stride-4 convolution is (224−11)/4+1=54.25, which does not give 55×55. Implementations make the numbers work either by using a 227×227 input or by adding padding of 2 on each side (PyTorch's torchvision does the latter).
Splitting across two GPUs
Because the network did not fit in the memory of a single GPU (3GB), half of each layer's kernels were placed on each of the two GPUs. This is why the kernel depths (48 in conv2, 192 in conv4 and conv5) are half the number of channels of the previous layer. Communication between the GPUs is limited to certain layers.
Conv2, 4, 5: take as input only the outputs of the previous layer on the same GPU.
Conv3: takes as input the outputs of conv2 on both GPUs.
Fully connected layers: connect to all neurons of the previous layer.
This way of connecting, in which a layer takes only part of the previous layer's channels as input, corresponds to what is now called grouped convolution (with 2 groups).
Local response normalization (LRN)
After the ReLU of conv1 and conv2, a normalization is applied that divides values by those of neighboring kernels at the same position. If ax,yi is the ReLU output of kernel i at position (x,y), the normalized output bx,yi is given by the following formula.
N is the number of kernels in the layer, and the sum is taken over n neighboring kernels. The paper uses k=2, n=5, α=10−4, and β=0.75. Kernels that respond strongly suppress the outputs of their neighbors, and the paper explains that this was inspired by the "lateral inhibition" found in real neurons.
Overlapping pooling
With a pooling window size z and spacing (stride) s, pooling traditionally used s=z, so windows did not overlap. AlexNet uses z=3 and s=2, so that neighboring windows overlap slightly.
Training
AlexNet minimizes cross-entropy (maximizing the average log-probability of the correct class) with SGD with momentum. Its 60 million parameters are too many for 1.2 million images and would overfit heavily as they are, so data augmentation and dropout are combined.
Data preprocessing
The shorter side of each image is rescaled to 256, and the central 256×256 patch is cropped. The only other preprocessing is subtracting the mean pixel value of the training data.
Data augmentation
A random 224×224 patch is cropped from the 256×256 image and randomly flipped horizontally. This increases the training data by a factor of 2048 (although the resulting images are highly similar to one another).
The intensities of the RGB values of pixels are altered. Principal component analysis (PCA) is applied in advance to the RGB values of the entire training set to obtain the eigenvectors pi and eigenvalues λi of the 3×3 covariance matrix, and the following quantity is added to each pixel Ixy of the image.
[p1,p2,p3][α1λ1,α2λ2,α3λ3]⊤
αi is drawn once per image from a normal distribution with mean 0 and standard deviation 0.1. This teaches the model a property of natural images: the kind of object does not change when the color or brightness of the lighting changes.
At test time, the predictions on 10 patches, the four corner and center 224×224 patches and their horizontal flips, are averaged.
Dropout
In the first two fully connected layers, the output of each neuron is set to 0 with probability 0.5. At test time, all neurons are used and their outputs are multiplied by 0.5. Without dropout the network overfit heavily, but dropout roughly doubled the number of updates needed to converge.
Starts at 0.01 and is divided by 10 when the validation error stops improving (3 times before termination)
Training length
About 90 epochs (5–6 days on two GTX 580s)
Weight initialization
Normal distribution with mean 0 and standard deviation 0.01
Bias initialization
1 for conv2, 4, 5 and the hidden fully connected layers, 0 for the others
The weight update rule is as follows. i is the iteration index, v is the momentum variable, ϵ is the learning rate, and the last term is the gradient averaged over the mini-batch Di.
The paper states that this small weight decay was important not only as a regularizer but also for reducing the training error. The biases are set to 1 to give ReLUs positive inputs and speed up the early stage of training.
Why it worked
AlexNet's success came not so much from a single new mechanism as from combining techniques for training a large model in a realistic amount of time with techniques for suppressing overfitting. The paper lists its architectural choices in order of their estimated importance.
ReLU speeds up training: tanh and the sigmoid saturate for large inputs, which makes their gradients small. With the non-saturating ReLU (f(x)=max(0,x)), a 4-layer CNN on CIFAR-10 reached a 25% training error rate in one sixth of the time needed with tanh. The paper states that experiments with a network of this size would not have been possible with tanh.
Two GPUs allow a large model: a network too large for one GPU could be trained. Compared with a network trained on one GPU with half the kernels in each layer, the top-1 and top-5 error rates dropped by 1.7 and 1.2 points.
Local response normalization: reduced the top-1 and top-5 error rates by 1.4 and 1.2 points. On a 4-layer CNN for CIFAR-10, the test error also dropped from 13% to 11%.
Overlapping pooling: compared with non-overlapping pooling producing outputs of the same size (s=z=2), it reduced the top-1 and top-5 error rates by 0.4 and 0.3 points and made the model less prone to overfitting.
Data augmentation and dropout: the color-altering augmentation alone reduced the top-1 error rate by more than 1 point. The paper states that without cropping and flipping, the network would have overfit heavily and a much smaller network would have been necessary.
As an everyday analogy, AlexNet is a car fitted with both "a powerful engine (GPUs and ReLU)" and "brakes that keep it from swerving (data augmentation and dropout)". With only one of the two, the large model could not have been driven all the way.
The paper reports that depth itself also matters. Each convolutional layer holds no more than 1% of the parameters, yet removing any one of the middle layers lowered the top-1 accuracy by about 2 points. This view that "deeper is better" led to later work such as VGG and ResNet.
Experimental results
ILSVRC-2010 test data (error rate %)
Model
top-1
top-5
Sparse coding (best in the competition)
47.1
28.2
SIFT + Fisher Vectors (best before AlexNet)
45.7
25.7
AlexNet (single CNN)
37.5
17.0
AlexNet's values are averages of predictions over 10 patches. Without averaging, they were 39.0% and 18.3%.
ILSVRC-2012 (error rate %; the test labels are not public, so validation values are also shown)
Model
top-1 (val)
top-5 (val)
top-5 (test)
SIFT + Fisher Vectors (2nd in the competition)
—
—
26.2
1 CNN
40.7
18.2
—
Average of 5 CNNs
38.1
16.4
16.4
1 CNN (pre-trained)
39.0
16.6
—
Average of 7 CNNs (2 pre-trained)
36.7
15.4
15.3
"Pre-trained" means a CNN with one extra convolutional layer, trained on the whole of ImageNet (Fall 2011 release, 15 million images, 22,000 classes) and then fine-tuned on ILSVRC-2012. Training on the larger data first lowered the error of a single model from 18.2% to 16.6%.
On the Fall 2009 release of ImageNet (10,184 classes, 8.9 million images; half used for training and half for testing), the top-1 and top-5 error rates were 67.4% and 40.9%, far better than the previous best of 78.1% and 60.9%.
The paper also shows that images whose outputs at the last hidden layer (4096 dimensions) are close depict the same kind of object even when their pixel values differ. This means that the output can be used as a feature that captures the meaning of an image.
Caveats when using it
When using AlexNet today, keep the following points in mind.
The AlexNet in libraries differs slightly from the paper: the AlexNet in PyTorch's torchvision is based on the form described in Krizhevsky's 2014 paper (One weird trick). Conv1, 2, and 4 have 64, 192, and 256 kernels (96, 256, and 384 in the paper), there is no local response normalization, and it runs on a single GPU. The ImageNet accuracy of the pre-trained weights is 56.5% top-1 and 79.1% top-5 (official documentation).
Most of the parameters are in the fully connected layers: the fully connected layer from 6×6×256 = 9216 dimensions to 4096 dimensions alone has about 38 million parameters. Since the model is heavy for its accuracy, it is more common to choose ResNet, MobileNet, or similar models as the backbone of a new system.
Local response normalization has fallen out of use: the later VGG paper reports that adding LRN did not improve ImageNet accuracy and only increased memory and computation time. Today batch normalization is used instead.
Dropout scaling is handled differently: the paper multiplies outputs by 0.5 at test time, whereas PyTorch's nn.Dropout multiplies the retained outputs by 1/(1−p) during training and does nothing at test time. Both give the same expected value. If model.eval() is forgotten, dropout is applied during inference as well.
PyTorch's nn.LocalResponseNorm multiplies the sum by α/n rather than α (n is size). To reproduce the paper's α=10−4 and n=5, use nn.LocalResponseNorm(size=5, alpha=5e-4, beta=0.75, k=2.0). The default k=1.0 also differs from the paper's k=2.
Comparison with other models
After AlexNet, the error rate in ILSVRC image classification kept falling as networks became deeper. Compared from the same viewpoints, the models look like this (error rates are top-5 on the ILSVRC test data from each paper, for ensembles of models).
VGG replaced AlexNet's large 11×11 and 5×5 kernels with stacks of 3×3 kernels, and GoogLeNet improved accuracy with one twelfth of AlexNet's parameters. ResNet solved the problem that deeper networks are harder to train by using shortcut connections, making depths of over 100 layers possible.
Rough guidelines for choosing are as follows.
To learn the history and basic building blocks of CNNs: AlexNet has few layers, making it easy to follow the roles of convolution, pooling, fully connected layers, and dropout, so it is well suited as teaching material.
For practical image classification or transfer learning: choose ResNet-50, which balances accuracy and computation well, or lightweight models such as MobileNet and EfficientNet.
When a large amount of data is available: Transformer-based models such as ViT are also candidates.
PyTorch example
▶Show code
python
import torch
import torch.nn as nn
from PIL import Image
from torchvision.models import alexnet, AlexNet_Weights
"""
Example of loading torchvision's pre-trained AlexNet and classifying an image
(torchvision's AlexNet follows the "One weird trick" paper: the numbers of convolution kernels differ from the original paper, and there is no local response normalization)
"""
weights = AlexNet_Weights.IMAGENET1K_V1 # Same as AlexNet_Weights.DEFAULT. With weights=None, the weights are random
model = alexnet(weights=weights)
model.eval() # Disable dropout (if forgotten, outputs are randomly zeroed even at inference)
# Preprocessing comes with the weights: resize the shorter side to 256, center-crop 224×224, normalize by mean and std
preprocess = weights.transforms()
image = Image.open("cat.jpg").convert("RGB")
x = preprocess(image).unsqueeze(0) # [1, 3, 224, 224]
with torch.no_grad():
logits = model(x) # [1, 1000]
probs = logits.softmax(dim=1)
top5 = probs.topk(5, dim=1)
categories = weights.meta["categories"] # Names of the 1000 classes
for p, i in zip(top5.values[0], top5.indices[0]):
print(f"{categories[i]}: {p.item():.3f}")
# Contents: features (convolution and pooling) → avgpool (resize to 6×6) → classifier (dropout and fully connected layers)
print(model.features[0]) # Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))
# Replacing the head for 10-class classification and fine-tuning
model.classifier[6] = nn.Linear(4096, 10)
model.train() # Enable dropout
# Writing the paper's local response normalization (k=2, n=5, α=1e-4, β=0.75) in PyTorch.
# PyTorch multiplies the sum by alpha / size, so set alpha to 1e-4 × 5
lrn = nn.LocalResponseNorm(size=5, alpha=5e-4, beta=0.75, k=2.0)
FAQ
Q. Why is AlexNet called a turning point for deep learning?
A.
Because it won a large-scale ImageNet competition (ILSVRC-2012) by a wide margin over methods that used hand-designed features. Its top-5 error rate was 15.3%, versus 26.2% for second place. It showed that, given large data and GPUs, deep CNNs can learn features by themselves, and image recognition research afterwards came to center on deep CNNs.
Q. Is local response normalization (LRN) still used?
A.
Hardly at all. In the VGG paper, adding LRN did not improve ImageNet accuracy and only increased memory and computation time. Today batch normalization and similar methods are used instead. PyTorch still provides nn.LocalResponseNorm, but it differs from the paper's formula in that it multiplies the sum by α/n.
Q. Was AlexNet split across two GPUs for accuracy?
A.
The main reason was that the network did not fit on a single GPU (3GB of memory). In the paper, splitting across two GPUs gave top-1 and top-5 error rates 1.7 and 1.2 points lower than a network trained on one GPU with half the kernels. This split corresponds to today's grouped convolution (with 2 groups).