
AlexNet is a deep convolutional neural network for image classification that won the ImageNet ILSVRC-2012 challenge by a huge margin: 15.3% top-5 error against 26.2% for the second-best entry. It was created by Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton at the University of Toronto and described in the paper “ImageNet Classification with Deep Convolutional Neural Networks” (NIPS 2012). The network has eight learned layers, five convolutional and three fully connected, about 61 million parameters, and it was trained for five to six days on two NVIDIA GTX 580 gaming graphics cards. AlexNet showed that a large neural network trained on GPUs with lots of labeled data beats hand-engineered computer vision, and it started the deep learning boom that led to today’s AI.
This guide explains the AlexNet architecture layer by layer, the ideas that made it work, how it was trained and what it achieved. It includes PyTorch code for the pretrained torchvision model, an implementation of the original 2012 network with a way to load its original weights, and a Keras version. We also ran our own experiments: we reproduced the paper’s ReLU vs tanh test, checked what the two GPUs learned, measured AlexNet’s speed on a CPU against modern networks and tested how useful its features still are for transfer learning.
Key takeaways
- AlexNet = 5 convolutional + 3 fully connected layers. The first layer applies 96 large 11×11 filters with stride 4; then come 5×5 and 3×3 convolutions, overlapping max pooling, ReLU after every layer and dropout in the first two fully connected layers.
- 61 million parameters, 0.72 billion multiply-accumulate operations per image. 96% of the parameters sit in the fully connected layers (the first one alone holds 62%), but 92% of the computation happens in the convolutional layers. The often-quoted 62.3 million is the one-GPU version without grouped convolutions.
- The famous 15.3% top-5 error is the ILSVRC-2012 result of an ensemble of seven networks. A single AlexNet had 18.2% top-5 and 40.7% top-1 error on the validation set; torchvision’s pretrained AlexNet reaches 56.5% top-1 and 79.1% top-5 accuracy.
- We reproduced the paper’s ReLU test: a four-layer CNN with ReLU reached 25% training error on CIFAR-10 in 6 epochs, the same network with tanh needed 10, 1.7 times longer. The paper reported a sixfold difference.
- The two-GPU split shaped what the network learned. In the original weights, 44 of the 48 first-layer filters in one group respond to color and 41 of the 48 in the other group are grayscale, exactly the specialization the authors described.
- In 2026 AlexNet is a teaching model, not a backbone. On a 2-core CPU it needs 19 ms per image, about as much as EfficientNet-B0, which has 11.5 times fewer parameters and is 21 points more accurate on ImageNet. In our pet-breed test, frozen AlexNet features reached 81.1% accuracy against 90.6% for VGG16 and 93.6% for ResNet-50. AlexNet still lives on as the default backbone of the LPIPS image similarity metric.
What is AlexNet?
AlexNet is a deep convolutional neural network (CNN) that takes a color photo and assigns it to one of the 1,000 ImageNet classes, from “tabby cat” to “container ship”. It is named after its first author, Alex Krizhevsky, a graduate student in Geoffrey Hinton’s group at the University of Toronto. The second author, Ilya Sutskever, was another student of Hinton. At the competition the team was called SuperVision; the name AlexNet came later.
The architecture itself was not new. Convolutional networks trained with backpropagation date back to Yann LeCun’s work of 1989–1998, whose LeNet read handwritten digits on bank checks. AlexNet was the same kind of network scaled up: about 60 million parameters instead of LeNet-5’s 60 thousand, trained on 1.2 million color photos instead of tens of thousands of small grayscale digits. Three things made this scale possible in 2012: the ImageNet dataset with millions of labeled images, graphics cards fast enough to train such a network in days, and a few practical tricks (ReLU, dropout, data augmentation) that sped up training and kept the network from overfitting.

The results were presented in October 2012 at the ImageNet workshop in Florence, and the paper appeared at the NIPS conference that December. For computer vision researchers it was a shock: the best system in the main benchmark of the field was a neural network, and it was ahead of the best hand-engineered pipeline by more than 10 points of top-5 error. Within two years nearly every top entry in the ImageNet challenge was a convolutional network, and the same approach spread to speech, text and, eventually, the large language models of today. Our guide on deep learning covers this wider story.
The AlexNet paper: ImageNet Classification with Deep Convolutional Neural Networks
The paper “ImageNet Classification with Deep Convolutional Neural Networks” by Krizhevsky, Sutskever and Hinton was published in Advances in Neural Information Processing Systems 25, the proceedings of NIPS 2012 (now NeurIPS). It is only nine pages long and reads like an engineering report: most of the text explains individual design choices and how much each one reduced the error.
| What | AlexNet, 2012 |
|---|---|
| Training data | about 1.2 million ImageNet photos in 1,000 classes (ILSVRC); 50,000 validation and 150,000 test images |
| Network | 5 convolutional + 3 fully connected layers, 650,000 neurons, 60 million parameters |
| Input | 224×224 crops of images downscaled to 256×256 (227×227 in practice, see below) |
| Training | stochastic gradient descent, batch 128, momentum 0.9, weight decay 0.0005, about 90 epochs |
| Hardware and time | two NVIDIA GTX 580 GPUs with 3 GB of memory each, five to six days |
| ILSVRC-2010 test set | 37.5% top-1 and 17.0% top-5 error; the best earlier result was 45.7% and 25.7% |
| ILSVRC-2012 test set | 15.3% top-5 error (ensemble of seven networks); second place 26.2% |
| Code | Krizhevsky’s cuda-convnet; the original 2012 code was released by the Computer History Museum and Google in March 2025 |
Ten years later, in 2022, the paper received the NeurIPS Test of Time Award, given to the most influential paper presented at the conference a decade earlier. The program chairs wrote that it was the first CNN trained for the ImageNet challenge, far surpassed the state of the art and had a huge impact on the machine learning community.
AlexNet architecture
AlexNet is a straight stack of layers with no branches or skip connections. It turns a 227×227×3 image into a 6×6×256 block of features with five convolutional layers and then classifies it with three fully connected layers. The diagram at the top of this article shows the size of every feature map.
Layer by layer:
- Conv1: 96 filters of 11×11×3 with stride 4 → 55×55×96, ReLU, local response normalization, max pooling 3×3 with stride 2 → 27×27×96.
- Conv2: 256 filters of 5×5×48 with padding 2 → 27×27×256, ReLU, local response normalization, max pooling → 13×13×256. Each filter sees only the 48 feature maps on its own GPU.
- Conv3: 384 filters of 3×3×256 → 13×13×384, ReLU. This is the only convolutional layer that connects the two GPUs: each filter sees all 256 maps.
- Conv4: 384 filters of 3×3×192 → 13×13×384, ReLU.
- Conv5: 256 filters of 3×3×192 → 13×13×256, ReLU, max pooling → 6×6×256, or 9,216 numbers.
- FC6: 4,096 neurons, ReLU, dropout.
- FC7: 4,096 neurons, ReLU, dropout.
- FC8: 1,000 neurons and softmax, one probability per class.
224 or 227? The paper says the input is 224×224, but with an 11×11 filter, stride 4 and no padding, that gives (224 − 11) / 4 + 1 = 54.25 positions, not the 55 shown in the paper. The numbers only work for 227×227: (227 − 11) / 4 + 1 = 55. Caffe’s reimplementation took 227×227 crops; torchvision keeps 224×224 and adds 2 pixels of padding to the first layer. Either way, each output of the last pooling layer sees a 195×195-pixel window of the input image.
Grouped convolutions. Conv2, conv4 and conv5 are split into two independent halves, one per GPU. Today this is called a grouped convolution with two groups (groups=2 in PyTorch and Keras). The split was forced by hardware, but the idea outlived it: ResNeXt uses many groups on purpose, and the depthwise convolutions of MobileNet are its extreme case, one group per channel.
AlexNet layers, parameters and computation
A convolutional layer with K filters of size h×w×C has K·(h·w·C + 1) parameters: for conv1 that is 96·(11·11·3 + 1) = 34,944. The first fully connected layer receives all 6·6·256 = 9,216 values of the last feature map, so it has 9,216·4,096 + 4,096 = 37,752,832 parameters. The table counts multiply-accumulate operations (MACs) for one 227×227 image.
| Layer | Configuration | Output | Parameters | MACs, millions |
|---|---|---|---|---|
| Conv1 | 96 × 11×11×3, stride 4; LRN; max pool 3×3, stride 2 | 55×55×96 → 27×27×96 | 34,944 | 105.4 |
| Conv2 | 256 × 5×5×48, 2 groups; LRN; max pool | 27×27×256 → 13×13×256 | 307,456 | 223.9 |
| Conv3 | 384 × 3×3×256 | 13×13×384 | 885,120 | 149.5 |
| Conv4 | 384 × 3×3×192, 2 groups | 13×13×384 | 663,936 | 112.1 |
| Conv5 | 256 × 3×3×192, 2 groups; max pool | 13×13×256 → 6×6×256 | 442,624 | 74.8 |
| FC6 | fully connected 9,216 → 4,096; ReLU, dropout | 4,096 | 37,752,832 | 37.7 |
| FC7 | fully connected 4,096 → 4,096; ReLU, dropout | 4,096 | 16,781,312 | 16.8 |
| FC8 | fully connected 4,096 → 1,000; softmax | 1,000 | 4,097,000 | 4.1 |
| Total | 5 conv + 3 FC layers | 60,965,224 | 724.4 |
In total the original AlexNet has 60,965,224 parameters and performs 724 million multiply-accumulate operations per image, or about 1.45 billion floating-point operations. In 32-bit floats the weights take 244 MB.
The distribution is very uneven. The five convolutional layers hold only 2.3 million parameters (3.8%) but do 92% of the computation. The three fully connected layers hold 58.6 million parameters (96.2%) and do only 8% of the work; FC6 alone has 37.8 million, 62% of the network. Later architectures fixed exactly this: from 2014 on, most CNNs replaced the large dense layers with global average pooling.

Why do sources say 60, 61 or 62 million parameters? The paper rounds to 60 million; the exact count of the two-GPU network is 61.0 million. If conv2, conv4 and conv5 are connected to all channels, as in a one-GPU version without groups, the count grows to 62,378,344 and the computation to 1.14 billion MACs. These are the “62.3 million parameters and 1.1 billion operations” quoted in many tutorials, including an earlier version of this article. The AlexNet in torchvision has a different set of filters (64, 192, 384, 256 and 256) and 61,100,840 parameters.
What made AlexNet work
None of AlexNet’s components was invented from scratch, but the paper combined them into a recipe that made a network of this size trainable and kept it from memorizing the training set. The authors measured the effect of almost every choice.
ReLU instead of tanh
Neural networks of the time mostly used saturating activation functions such as tanh or the sigmoid. Their gradient almost vanishes for large inputs, which slows down gradient descent. AlexNet used the rectified linear unit, ReLU: f(x) = max(0, x). Its gradient is 1 for any positive input. In the paper, a four-layer CNN with ReLU reached 25% training error on CIFAR-10 six times faster than the same network with tanh. Without this speed-up, the authors wrote, they could not have experimented with such large networks. ReLU and its descendants, such as GELU and SwiGLU, have been the default ever since.
We repeated this experiment; the results are below.
Our replication. We built a four-layer convolutional network of the kind the authors used for CIFAR-10, a dataset that Krizhevsky himself had put together in 2009: three 5×5 convolutional layers with 32, 32 and 64 filters, each followed by pooling, and a fully connected output layer, without normalization, dropout or weight decay. We trained it on all 50,000 CIFAR-10 training images with stochastic gradient descent (momentum 0.9, batches of 128), once with ReLU and once with tanh. As in the paper, the learning rate was chosen separately for each activation, from 0.003, 0.01, 0.03 and 0.1.

With its best learning rate, 0.03, the ReLU network reached 25% training error in 6 epochs. The tanh network, also at its best rate of 0.03, needed 10 epochs, 1.7 times longer. A second run with a different random seed gave the same result, 6 and 10 epochs. So the effect is real, but smaller than the sixfold gap in the paper: our network, initialization and training code differ from the original, and the authors themselves noted that the size of the effect depends on the architecture. ReLU also turned out to be less forgiving: at a learning rate of 0.1 our ReLU network stopped learning altogether and stayed at 90% error, the level of random guessing among 10 classes, while the tanh network kept improving.
Dropout
During training, dropout sets the output of each neuron in FC6 and FC7 to zero with probability 0.5. A neuron cannot rely on the presence of particular other neurons, so the network learns more robust features, and each training step effectively trains a different thinned network. According to the paper, without dropout AlexNet overfit substantially; with it, training needed about twice as many iterations to converge. At test time all neurons are used and their outputs are scaled by 0.5. PyTorch and Keras do the scaling during training instead, which is equivalent.
Data augmentation
60 million parameters cannot be trained on 1.2 million images without heavy overfitting, so the authors enlarged the dataset artificially in two ways:
- Random crops and flips. Each training image was downscaled to 256×256, and the network saw a random 224×224 patch of it, possibly flipped horizontally. That gives 32·32·2 = 2,048 variants of every image. At test time the network averaged its predictions over 10 patches: the four corners and the center, plus their mirror images.
- Color augmentation. The authors computed the principal components of RGB pixel values over the training set and added random multiples of them to every image, which simulates changes in lighting and color. This reduced top-1 error by over 1%.
Both transformations were computed on the CPU while the GPUs trained on the previous batch, so they were free.
Local response normalization (LRN)
Local response normalization divides each ReLU output by the activity of the same position in neighboring channels. The idea comes from lateral inhibition in real neurons: a strongly excited neuron suppresses its neighbors. In the paper’s notation:
bix,y = aix,y / (k + α · Σj (ajx,y)2)β
Here aix,y is the output of filter i at position (x, y), and the sum runs over n = 5 adjacent channels, from i − 2 to i + 2. The constants are k = 2, α = 10−4 and β = 0.75. LRN is applied after the ReLU of conv1 and conv2. According to the paper, it reduced the top-1 and top-5 error on ImageNet by 1.4% and 1.2%, and on CIFAR-10 a four-layer network went from 13% to 11% test error.
A trap in PyTorch: nn.LocalResponseNorm divides α by the window size n. To reproduce the paper, pass alpha=5e-4, not 1e-4: nn.LocalResponseNorm(size=5, alpha=5e-4, beta=0.75, k=2.0). TensorFlow’s tf.nn.local_response_normalization does not divide, so there the paper’s values work as is, with depth_radius=2.
LRN did not survive. The VGG authors found in 2014 that it does not improve accuracy on ImageNet but adds memory use and computation, and from 2015 batch normalization took over its role.
Overlapping pooling
Before AlexNet, pooling windows usually did not overlap: a 2×2 window moved in steps of 2. AlexNet used 3×3 windows with stride 2, so neighboring windows share a row or a column. This reduced top-1 and top-5 error by 0.4% and 0.3% compared with 2×2 pooling, and the authors noticed that such networks were slightly harder to overfit.
Two GPUs
The GTX 580 had 3 GB of memory, too little for the whole network and its activations during training. The authors split every layer between two GPUs: each holds half of the filters, and the halves communicate only in conv3 and in the fully connected layers. Compared with a one-GPU network with half as many filters, the two-GPU network had 1.7% lower top-1 and 1.2% lower top-5 error and trained slightly faster.
An unexpected side effect is visible in the first layer. The paper notes that the filters on one GPU became largely color-agnostic and those on the other color-specific, and that this happened in every training run. We checked whether the specialization shows up in the weights that are publicly available today.
We took the BVLC AlexNet weights (more about them in the PyTorch section below): their conv2, conv4 and conv5 are split into two groups exactly as in the paper. For each of the 96 first-layer filters we measured how much of its energy lies in differences between the red, green and blue channels, and called a filter a color filter when that share was above 30%.

The result matches the paper almost perfectly. In the first group, 44 of the 48 filters are color filters: blobs and gradients of color. In the second group only 7 are, while the other 41 are grayscale detectors of edges and stripes at different angles. The reason is the restricted connectivity: conv2 on each GPU sees only the 48 maps of its own half, so each half develops its own specialization. For comparison, we ran the same measurement on a one-GPU AlexNet without groups from the imgclsmob model collection: there the color filters are spread evenly, 20 and 22 of 48 in the two halves.
How AlexNet was trained
AlexNet was trained with stochastic gradient descent with momentum on batches of 128 images. The update rule for each weight w was:
vi+1 = 0.9 · vi − 0.0005 · ε · wi − ε · ∂L/∂w
wi+1 = wi + vi+1
where i is the iteration number, v is the momentum variable, ε is the learning rate and ∂L/∂w is the gradient of the loss averaged over the batch. The term with 0.0005 is weight decay. The authors noted that this small amount of weight decay was important for learning: it reduced the training error, not just overfitting.
Other details:
- Initialization. Weights were drawn from a normal distribution with mean 0 and standard deviation 0.01. Biases in conv2, conv4, conv5 and the fully connected hidden layers were set to 1, so that ReLUs received positive inputs from the start; all other biases were 0.
- Learning rate. The same for all layers, starting at 0.01. When the validation error stopped improving, the authors divided it by 10 by hand. This happened three times.
- Duration. About 90 passes through the 1.2 million training images, five to six days on two GTX 580 GPUs. Each card had a peak of about 1.6 trillion floating-point operations per second.
- Code. Krizhevsky wrote his own CUDA library for convolutions, cuda-convnet. Its version as of 2012, together with parameter files trained on ImageNet, is now available in the Computer History Museum’s GitHub repository under the BSD-2 license.
By our estimate, the whole training run took about 4.7·1017 floating-point operations: 1.45 billion per image in the forward pass, three times as many with the backward pass, times 1.2 million images and 90 epochs. Epoch AI estimates that Grok 4, one of the largest models of 2025, was trained with about 5·1026 operations, a billion times more. In the other direction, algorithms became more efficient: OpenAI calculated that in 2019 reaching AlexNet’s accuracy required 44 times less computation than in 2012, while Moore’s law alone would have given an 11-fold gain over the same period. If you plan to train networks yourself, see our guide to the best GPUs for AI.
AlexNet results on ImageNet
The paper reports results on two versions of the ImageNet challenge. On ILSVRC-2010, the only version with public test labels, a single AlexNet cut the top-5 error from 25.7% to 17.0%:
| ILSVRC-2010, test set | Top-1 error | Top-5 error |
|---|---|---|
| Sparse coding (best entry of the 2010 challenge) | 47.1% | 28.2% |
| SIFT + Fisher vectors (best published result before AlexNet) | 45.7% | 25.7% |
| AlexNet | 37.5% | 17.0% |
For ILSVRC-2012, the team submitted ensembles. Averaging five networks brought the top-5 error down to 16.4%. For the winning entry they also pre-trained two networks with an extra sixth convolutional layer on the full Fall 2011 release of ImageNet, 15 million images in 22,000 categories, fine-tuned them on the challenge data and averaged seven networks in total:
| ILSVRC-2012 | Top-1 error, validation | Top-5 error, validation | Top-5 error, test |
|---|---|---|---|
| SIFT + Fisher vectors (second place) | – | – | 26.2% |
| 1 AlexNet | 40.7% | 18.2% | – |
| 5 AlexNets | 38.1% | 16.4% | 16.4% |
| 1 AlexNet pre-trained on ImageNet Fall 2011 | 39.0% | 16.6% | – |
| 7 AlexNets, 2 of them pre-trained | 36.7% | 15.4% | 15.3% |
Top-5 error counts an answer as correct if the right class is among the network’s five most likely guesses; top-1 counts only the first guess. The authors also showed that depth mattered: removing any of the middle convolutional layers raised the top-1 error by about 2%. On an even larger task, the Fall 2009 version of ImageNet with 10,184 categories and 8.9 million images, a version of AlexNet with a sixth convolutional layer reached 67.4% top-1 and 40.9% top-5 error, compared with 78.1% and 60.9% for the best published method.

The right half of this figure was perhaps the most important result for the future. Images that are close in the space of the 4,096 neurons of FC7 belong to the same class even when they look nothing alike pixel by pixel: dogs and elephants appear in a variety of poses. The network had learned a general-purpose description of images. Researchers soon used such features from pretrained networks for other tasks, which became known as transfer learning.
In the following years the error in the challenge kept falling, and by 2015 networks were better than the human estimate:

AlexNet in PyTorch
torchvision ships a pretrained AlexNet, but it is not exactly the network from the 2012 paper. It is the “one weird trick” version from Krizhevsky’s 2014 paper on parallel training: a single tower with 64, 192, 384, 256 and 256 filters, no local response normalization, no groups and an adaptive pooling layer before the classifier. It has 61.1 million parameters and reaches 56.5% top-1 and 79.1% top-5 accuracy on ImageNet. If you are new to the framework, start with our PyTorch tutorial.
Classify an image with pretrained AlexNet
import torch
from PIL import Image
from torchvision.models import alexnet, AlexNet_Weights
weights = AlexNet_Weights.IMAGENET1K_V1 # 233 MB, downloaded on first use
model = alexnet(weights=weights).eval()
preprocess = weights.transforms() # resize 256, center crop 224, ImageNet mean/std
img = Image.open("dog.jpg").convert("RGB")
with torch.inference_mode():
probs = model(preprocess(img).unsqueeze(0)).softmax(dim=1)[0]
top5 = probs.topk(5)
for p, i in zip(top5.values, top5.indices):
print(f"{weights.meta['categories'][i]:<28}{p:.3f}")
The script prints the five most likely ImageNet classes with their probabilities. weights.transforms() applies the same preprocessing as during training: resize the shorter side to 256 pixels, cut out the central 224×224 square and normalize the colors with the ImageNet mean and standard deviation.
AlexNet from scratch: the original 2012 architecture
This implementation follows the paper: two groups in conv2, conv4 and conv5, local response normalization after conv1 and conv2, overlapping 3×3 pooling with stride 2 and a 227×227 input.
import torch
from torch import nn
class AlexNet2012(nn.Module):
"""AlexNet as in the 2012 paper: two groups, LRN, overlapping pooling."""
def __init__(self, num_classes=1000, lrn_k=2.0, lrn_alpha=5e-4):
super().__init__()
def lrn(): # PyTorch divides alpha by size: 5e-4 here = 1e-4 in the paper
return nn.LocalResponseNorm(size=5, alpha=lrn_alpha, beta=0.75, k=lrn_k)
self.features = nn.Sequential(
nn.Conv2d(3, 96, kernel_size=11, stride=4), nn.ReLU(inplace=True), # conv1
lrn(), nn.MaxPool2d(kernel_size=3, stride=2),
nn.Conv2d(96, 256, kernel_size=5, padding=2, groups=2), nn.ReLU(inplace=True), # conv2
lrn(), nn.MaxPool2d(kernel_size=3, stride=2),
nn.Conv2d(256, 384, kernel_size=3, padding=1), nn.ReLU(inplace=True), # conv3
nn.Conv2d(384, 384, kernel_size=3, padding=1, groups=2), nn.ReLU(inplace=True), # conv4
nn.Conv2d(384, 256, kernel_size=3, padding=1, groups=2), nn.ReLU(inplace=True), # conv5
nn.MaxPool2d(kernel_size=3, stride=2),
)
self.classifier = nn.Sequential(
nn.Dropout(0.5), nn.Linear(256 * 6 * 6, 4096), nn.ReLU(inplace=True), # fc6
nn.Dropout(0.5), nn.Linear(4096, 4096), nn.ReLU(inplace=True), # fc7
nn.Linear(4096, num_classes), # fc8
)
def forward(self, x): # x: (batch, 3, 227, 227)
x = self.features(x) # (batch, 256, 6, 6)
return self.classifier(torch.flatten(x, 1))
model = AlexNet2012()
print(sum(p.numel() for p in model.parameters())) # 60965224
print(model(torch.randn(1, 3, 227, 227)).shape) # torch.Size([1, 1000])
The parameter count matches our table: 60,965,224. If you remove groups=2, you get the one-GPU variant with 62,378,344 parameters.
Run the original AlexNet weights
The original 2012 weights were never published in a common format. The closest public replica is BVLC AlexNet, trained by the Caffe team at Berkeley following the paper. It differs in two details: no color (PCA) augmentation and initial biases of 0.1 instead of 1. It reaches 57.1% top-1 and 80.2% top-5 accuracy on the ImageNet validation set from a single center crop. The ONNX Model Zoo keeps it as bvlcalexnet-12.onnx (244 MB). Its layers match our class exactly, so the weights can be copied over. Run this code in the same script, after the class above:
import onnx, torch
from onnx import numpy_helper
from PIL import Image
from torchvision.models import AlexNet_Weights
from torchvision.transforms import v2
# BVLC AlexNet from the ONNX Model Zoo: github.com/onnx/models (validated/vision/classification/alexnet)
w = {t.name: numpy_helper.to_array(t) for t in onnx.load("bvlcalexnet-12.onnx").graph.initializer}
model = AlexNet2012(lrn_k=1.0, lrn_alpha=1e-4).eval() # Caffe uses k = 1
layers = [m for m in model.modules() if isinstance(m, (torch.nn.Conv2d, torch.nn.Linear))]
names = ["conv1", "conv2", "conv3", "conv4", "conv5", "fc6", "fc7", "fc8"]
for layer, name in zip(layers, names):
weight = w[f"{name}_w_0"].copy()
if name == "conv1":
weight = weight[:, ::-1].copy() # Caffe expects BGR, we feed RGB
layer.weight.data = torch.from_numpy(weight)
layer.bias.data = torch.from_numpy(w[f"{name}_b_0"].copy())
# Caffe-style input: pixels 0-255 minus the mean ImageNet pixel, 227x227 crop
mean = torch.tensor([122.68, 116.67, 104.01]).view(3, 1, 1)
prep = v2.Compose([v2.Resize(256), v2.CenterCrop(227), v2.PILToTensor(), v2.ToDtype(torch.float32)])
x = prep(Image.open("dog.jpg").convert("RGB")) - mean
with torch.inference_mode():
probs = model(x.unsqueeze(0)).softmax(dim=1)[0]
categories = AlexNet_Weights.IMAGENET1K_V1.meta["categories"]
for p, i in zip(*probs.topk(5)):
print(f"{categories[i]:<28}{p:.3f}")
Output for the photo of a Samoyed from the PyTorch examples:
Samoyed 0.774
Great Pyrenees 0.048
Pomeranian 0.029
Arctic fox 0.021
kuvasz 0.019
We checked the conversion against ONNX Runtime: on random inputs the probabilities differ by at most 1.3·10−7. Caffe’s local response normalization uses k = 1 instead of the paper’s 2, so the class is created with lrn_k=1.0.
Fine-tune AlexNet on your own images
The usual way to use a pretrained network on a new task is to freeze the convolutional layers and train only the classifier. For AlexNet that means replacing FC8 with a layer for your classes:
import torch
from torch import nn
from torchvision.models import alexnet, AlexNet_Weights
num_classes = 37 # e.g. 37 cat and dog breeds
model = alexnet(weights=AlexNet_Weights.IMAGENET1K_V1)
for p in model.features.parameters():
p.requires_grad = False # freeze the five convolutional layers
model.classifier[6] = nn.Linear(4096, num_classes) # new output layer instead of FC8
optimizer = torch.optim.SGD(
[p for p in model.parameters() if p.requires_grad], lr=1e-3, momentum=0.9)
loss_fn = nn.CrossEntropyLoss()
def train_step(images, labels): # images: (batch, 3, 224, 224)
model.train()
loss = loss_fn(model(images), labels)
optimizer.zero_grad()
loss.backward()
optimizer.step()
return loss.item()
About 54.7 million parameters remain trainable, almost all of them in FC6 and FC7. For small datasets it is often better not to fine-tune at all and train a simple linear classifier on top of frozen features. Our experiment below shows which AlexNet layer to take them from.
AlexNet in Keras and TensorFlow
Keras has no AlexNet in keras.applications, so the network has to be defined by hand. Keras also has no local response normalization layer; the short LRN class below implements the formula from the paper with its original constants.
import keras
from keras import layers, ops
class LRN(layers.Layer):
"""Local response normalization across channels, with the paper's constants."""
def __init__(self, size=5, alpha=1e-4, beta=0.75, k=2.0, **kwargs):
super().__init__(**kwargs)
self.size, self.alpha, self.beta, self.k = size, alpha, beta, k
def call(self, x): # x: (batch, height, width, channels)
channels = x.shape[-1]
half = self.size // 2
sq = ops.pad(ops.square(x), [[0, 0], [0, 0], [0, 0], [half, half]])
total = sum(sq[..., i:i + channels] for i in range(self.size))
return x / ops.power(self.k + self.alpha * total, self.beta)
def alexnet(num_classes=1000):
return keras.Sequential([
keras.Input((227, 227, 3)),
layers.Conv2D(96, 11, strides=4, activation="relu"), # conv1
LRN(), layers.MaxPooling2D(3, strides=2),
layers.Conv2D(256, 5, padding="same", groups=2, activation="relu"), # conv2
LRN(), layers.MaxPooling2D(3, strides=2),
layers.Conv2D(384, 3, padding="same", activation="relu"), # conv3
layers.Conv2D(384, 3, padding="same", groups=2, activation="relu"), # conv4
layers.Conv2D(256, 3, padding="same", groups=2, activation="relu"), # conv5
layers.MaxPooling2D(3, strides=2),
layers.Flatten(),
layers.Dropout(0.5), layers.Dense(4096, activation="relu"), # fc6
layers.Dropout(0.5), layers.Dense(4096, activation="relu"), # fc7
layers.Dense(num_classes, activation="softmax"), # fc8
])
model = alexnet()
model.compile(optimizer=keras.optimizers.SGD(learning_rate=0.01, momentum=0.9),
loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.summary()
The summary shows 60,965,224 parameters, the same as in PyTorch. We tested the code with Keras 3.15. In TensorFlow you can also use the built-in tf.nn.local_response_normalization(x, depth_radius=2, bias=2.0, alpha=1e-4, beta=0.75); unlike PyTorch, it does not divide alpha by the window size. To compare the two frameworks in general, see PyTorch vs TensorFlow.
Experiment: are AlexNet features still useful?
Most people who use AlexNet today take it as a pretrained feature extractor. We checked how good its features are against later networks, with the same test as in our VGG16 guide: the Oxford-IIIT Pet dataset, photos of 37 breeds of cats and dogs.
Setup. 50 training and 50 test photos per breed, 1,850 + 1,850 in total, chosen at random with a fixed seed. This is a new random draw, so the numbers for the other networks differ from the VGG16 guide by up to 1.7 points. Each network was frozen; we extracted features once and trained logistic regression on top (a linear probe), choosing the regularization strength by 5-fold cross-validation on the training set. We then repeated the training with only 5, 10 and 20 photos per breed, averaging over five random draws.
Networks. AlexNet with the BVLC weights, with features from three places: the last convolutional layer averaged over all positions (256 values), FC6 and FC7 (4,096 values each). The other networks are the same as in the VGG16 test: VGG16 with the original Oxford weights, ResNet-50 trained with the “ResNet strikes back” recipe, EfficientNet-B0 trained with RandAugment and ViT-B/16 pretrained on ImageNet-21k, 14 million images. CPU time is from our speed test in the next section: the original two-group AlexNet used here takes 26 ms per image, the torchvision version 19 ms.
| Network and layer | Feature size | CPU time per image | 5 photos per breed | 10 | 20 | 50 |
|---|---|---|---|---|---|---|
| AlexNet, conv5 + average pooling | 256 | 26 ms | 43.3% | 54.7% | 62.9% | 71.0% |
| AlexNet, FC6 | 4,096 | 26 ms | 52.2% | 65.1% | 73.0% | 79.5% |
| AlexNet, FC7 | 4,096 | 26 ms | 62.9% | 72.3% | 77.3% | 81.1% |
| VGG16, FC7 | 4,096 | 152 ms | 81.8% | 86.5% | 88.4% | 90.6% |
| ResNet-50 | 2,048 | 62 ms | 86.3% | 89.1% | 91.6% | 93.6% |
| EfficientNet-B0 | 1,280 | 21 ms | 85.6% | 90.0% | 91.7% | 93.1% |
| ViT-B/16, ImageNet-21k | 768 | 189 ms | 87.8% | 89.3% | 92.5% | 93.5% |

What the results show:
- Take AlexNet features from FC7. With 50 photos per breed FC7 gave 81.1%, FC6 79.5% and the averaged last convolutional layer only 71.0%. With 5 photos the gap grows: 62.9% against 52.2% and 43.3%. In VGG16, FC6 and FC7 gave the same accuracy with 50 photos per breed; in AlexNet FC7 is ahead even there, and with 5 photos its lead over FC6 is 11 points against 4 in VGG16.
- AlexNet is far behind everything that came after it. VGG16 is 9.5 points better with 50 photos per breed and 19 points better with 5. ResNet-50 makes three times fewer mistakes: 6.4% of the test photos against 18.9%.
- Five photos with a modern network beat fifty with AlexNet. ResNet-50, EfficientNet-B0 and ViT-B/16 reached 85.6–87.8% with 5 photos per breed, more than AlexNet with 50.
- Speed is no excuse. EfficientNet-B0 runs as fast as AlexNet on a CPU, its feature vector is three times shorter (1,280 values instead of 4,096), and it is 12 points more accurate.
- Better training helps AlexNet, but not enough. torchvision-style AlexNet with weights retrained by the imgclsmob project (82.5% top-5 on ImageNet, against 80.2% for BVLC) reached 85.0% with 50 photos and 70.9% with 5 from FC7: about 4 and 8 points more than the BVLC weights, still behind VGG16.
- A caveat. ImageNet already contains many of these breeds, which helps every network in the test. On images unlike ImageNet, such as medical scans, the gaps can be different, so test a few backbones on your own data. A guide to the whole approach is in our article on transfer learning.
AlexNet vs LeNet, VGG16, ResNet and modern networks
The table compares AlexNet with the networks that came after it. Accuracy, parameters and operations are from torchvision’s model table; CPU time is our measurement for one image on a 2-core Intel Xeon at 2.3 GHz (PyTorch 2.15). The models ran in alternating rounds of 10 runs each, 16 to 21 rounds per model over three sessions, and the table shows the median. Absolute times depend on the machine and the session: in our VGG16 guide, measured in another session, the same models took 1.2 to 1.6 times longer, so compare models within one table.
| Model | Year | Parameters | GMACs | ImageNet top-1 | CPU, ms per image |
|---|---|---|---|---|---|
| AlexNet | 2012 | 61.1M | 0.71 | 56.5% | 19 |
| VGG16 | 2014 | 138.4M | 15.47 | 71.6% | 152 |
| GoogLeNet | 2014 | 6.6M | 1.50 | 69.8% | 41 |
| ResNet-50 | 2015 | 25.6M | 4.09 | 76.1% (80.9% with the newer recipe) | 62 |
| SqueezeNet 1.0 | 2016 | 1.2M | 0.82 | 58.1% | 19 |
| MobileNetV3-Large | 2019 | 5.5M | 0.22 | 74.0% | 14 |
| EfficientNet-B0 | 2019 | 5.3M | 0.39 | 77.7% | 21 |
| ViT-B/16 | 2020 | 86.6M | 17.56 | 81.1% | 189 |
| ConvNeXt-Tiny | 2022 | 28.6M | 4.46 | 82.5% | 59 |
- AlexNet vs LeNet. LeNet-5 (1998) has about 60 thousand parameters and recognizes 32×32 grayscale digits; AlexNet has a thousand times more parameters and works with 227×227 color photos of 1,000 kinds of objects. The building blocks are the same: convolutions, pooling and fully connected layers trained with backpropagation. New in AlexNet were ReLU instead of saturating activations, max pooling instead of averaging, dropout, heavy data augmentation and training on GPUs.
- AlexNet vs VGG16. VGG16 replaced AlexNet’s large 11×11 and 5×5 filters with stacks of 3×3 filters and doubled the depth to 16 layers. It is 15 points more accurate but needs 22 times more computation and runs about 8 times slower on a CPU.
- AlexNet vs GoogLeNet and ResNet. GoogLeNet won ILSVRC-2014 with Inception modules and global average pooling instead of large dense layers: 9 times fewer parameters than AlexNet. ResNet added skip connections and made networks with 50–152 layers trainable; ResNet-50 is 20–24 points more accurate than AlexNet.
- Efficient networks. SqueezeNet matched AlexNet’s accuracy in 2016 with 50 times fewer parameters. EfficientNet-B0 and MobileNetV3 run as fast as AlexNet on a CPU, have 11 times fewer parameters and are 18–21 points more accurate.
Everything that made AlexNet special has been replaced: LRN by batch normalization, large dense layers by global pooling, 11×11 filters by small ones, and plain stacks of layers by residual blocks. What remained is the recipe: a large network, a lot of data and GPUs.
Why AlexNet matters
AlexNet’s victory is often called the “ImageNet moment” of AI: the point at which neural networks went from a niche to the main approach in machine learning.
- Industry moved quickly. In 2012 Hinton, Krizhevsky and Sutskever founded the company DNNresearch, and in March 2013 Google acquired it. Both students moved to Google, and Hinton divided his time between the university and the company.
- The authors shaped the next decade. Sutskever co-founded OpenAI in 2015 and was its chief scientist until May 2024; in June 2024 he founded Safe Superintelligence (SSI) and has been its CEO since July 2025. Hinton received the 2024 Nobel Prize in Physics together with John Hopfield. Hinton has summed up the AlexNet story this way: Sutskever believed it should be done, Krizhevsky made it work, and he himself got the Nobel Prize.
- GPUs became the engine of AI. AlexNet showed that the bottleneck of neural networks was computation and that gaming graphics cards could remove it. From there grew the industry of AI accelerators and the compute race: from 4.7·1017 operations for AlexNet to around 1026 and more for the largest models of 2025–2026.
- The code became a museum piece. In March 2025 the Computer History Museum, after five years of negotiations with Google, published the original source code of AlexNet as it was in 2012.
Where AlexNet is used today
- Image similarity metrics. LPIPS, one of the standard metrics for comparing images in generation and super-resolution research, uses AlexNet features by default. Its authors recommend
net='alex'as the best forward metric and the VGG version for use as a training loss. - Teaching. AlexNet is small enough to read in one screen, has all the classic building blocks and a clear story, so it is still a standard example in courses on how neural networks work.
- A reference point. Work on model compression and efficient architectures long measured itself against AlexNet: Deep Compression shrank it 35 times, from 240 MB to 6.9 MB, without losing accuracy, and SqueezeNet was explicitly designed for “AlexNet-level accuracy”.
- Research on the original setup. When a paper studies grouped convolutions, local response normalization or the early history of deep learning, AlexNet is the natural baseline, and its original code is now available for that.
For new projects AlexNet is a poor choice: for image classification, detection or segmentation, modern backbones are faster and more accurate.
Limitations of AlexNet
- Bloated dense layers. 96% of the parameters and 244 MB of the weights are in the three fully connected layers, which do only 8% of the computation. Global average pooling, introduced soon after, removes most of them.
- A coarse first layer. 11×11 filters with stride 4 skip a lot of detail. Zeiler and Fergus showed in 2013 that this causes aliasing artifacts and dead filters, and their ZFNet, the basis of the 2013 winner, used 7×7 filters with stride 2.
- No batch normalization. Training depends on careful initialization and manual learning rate changes, and LRN costs computation without much benefit.
- Fixed input size. Because of the dense layers, the original network accepts only 227×227 images; torchvision added an adaptive pooling layer to work around it.
- Low accuracy by today’s standards. 56–57% top-1 on ImageNet against 80–90% for modern models.
More about architectures that followed is in the AI basics section.
FAQ
What is AlexNet used for?
It was designed to classify photos into 1,000 ImageNet categories. Today it is mostly used for teaching, as a historical baseline and as the default feature extractor in the LPIPS image similarity metric.
Who created AlexNet?
Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton from the University of Toronto. The network is named after Krizhevsky, the first author, who also wrote its GPU code.
How many layers does AlexNet have?
Eight layers with learnable weights: five convolutional and three fully connected. There are also three max pooling layers, two local response normalization layers and the final softmax, but they have no weights and are not counted.
How many parameters does AlexNet have?
The original two-GPU network has 60,965,224 parameters, about 61 million; the paper rounds this to 60 million. The one-GPU version without groups has 62.4 million, and torchvision’s AlexNet has 61.1 million.
What is the input size of AlexNet: 224 or 227?
The paper says 224×224, but the layer sizes in the paper only work out with 227×227. Caffe used 227×227 crops; torchvision uses 224×224 with padding in the first layer.
Why was AlexNet trained on two GPUs?
A GTX 580 had 3 GB of memory, not enough for the whole network during training. The authors split each layer in half between two cards; the halves exchange data only in conv3 and the fully connected layers.
What is the difference between AlexNet and VGG16?
VGG16 (2014) is twice as deep, uses only 3×3 filters, has 138 million parameters and is 15 points more accurate on ImageNet, but needs 22 times more computation.
Why do the numbers in the AlexNet abstract differ from the paper?
The abstract on the NeurIPS website comes from an earlier version: 1.3 million images, 500,000 neurons, two fully connected layers and 39.7% / 18.9% error. The published paper reports 1.2 million images, 650,000 neurons, three fully connected layers and 37.5% / 17.0% on the ILSVRC-2010 test set.
Where can I find the AlexNet paper and source code?
The paper is free on the NeurIPS proceedings website. The original 2012 code is in the Computer History Museum’s repository on GitHub; ready-to-use implementations are in torchvision and in the code above.
Is AlexNet still used in 2026?
Rarely in production. It remains a teaching model and part of the LPIPS metric. For a new project, take a modern backbone such as EfficientNet, ConvNeXt or a vision transformer.









[…] light and captures responses from the quantum dots. The team also wrote an algorithm using a public image analysis and machine learning network to interpret the signals and information… Read more »
[…] AlexNet (Image from https://neurohive.io/en/popular-networks/alexnet-imagenet-classification-with-deep-convolutional-neu…) […]
[…] AlexNet framework. Courtesy of https://neurohive.io/en/popular-networks/alexnet-imagenet-classification-with-deep-convolutional-neu… […]
[…] AlexNet – ImageNet Classification with Deep Convolutional Neural Networks […]