{"notes":[{"id":"classic-cnns/alexnet","category":"classic-cnns","legacyPath":"classic-cnns/1209-alexnet","legacySlug":"1209-alexnet","legacyPaths":[],"title":"AlexNet","subtitle":"The Rise of Convolutional Networks","author":"Z. Yuan","paperDate":"2012","publishedOn":"2024-06-30","paperTitle":"ImageNet Classification with Deep Convolutional Neural Networks","paperUrl":"https://proceedings.neurips.cc/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html","bibliography":{"title":"ImageNet Classification with Deep Convolutional Neural Networks","authors":["Alex Krizhevsky","Ilya Sutskever","Geoffrey E. Hinton"],"url":"https://proceedings.neurips.cc/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html","pdfUrl":"https://proceedings.neurips.cc/paper_files/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf","codeUrl":null,"preprint":null,"publication":{"venue":"NeurIPS (NIPS)","year":2012,"kind":"conference","url":"https://proceedings.neurips.cc/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html"},"citation":"@inproceedings{classiccnnsalexnet2012,\n  title = {{ImageNet Classification with Deep Convolutional Neural Networks}},\n  author = {Alex Krizhevsky and Ilya Sutskever and Geoffrey E. Hinton},\n  year = {2012},\n  booktitle = {NeurIPS (NIPS)},\n  url = {https://proceedings.neurips.cc/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html}\n}\n","citationPath":"/content/papers/citations/classic-cnns/alexnet.b38d2879f7bc.bib"},"thumbnail":{"src":"/content/papers/assets/87a5a48ff82989d4d78cc4d47a083f292fd7e249c1880c00ac4b31d8a042650d.jpg","width":1630,"height":570},"locale":"en","path":"/content/papers/en/classic-cnns/alexnet.c7dee680f897.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"relu-activation-function","text":"ReLU Activation Function","depth":3},{"id":"multi-gpu-training","text":"Multi-GPU Training","depth":3},{"id":"local-response-normalization","text":"Local Response Normalization","depth":3},{"id":"overlapping-max-pooling","text":"Overlapping Max Pooling","depth":3},{"id":"dropout","text":"Dropout","depth":3},{"id":"model-implementation","text":"Model Implementation","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"what-did-the-convolutional-network-learn","text":"What Did the Convolutional Network Learn?","depth":3},{"id":"ilsvrc-2010-results","text":"ILSVRC-2010 Results","depth":3},{"id":"ilsvrc-2012-results","text":"ILSVRC-2012 Results","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"classic-cnns/vgg","relation":"next","topic":"Training deeper convolutional networks"}]},{"id":"classic-cnns/vgg","category":"classic-cnns","legacyPath":"classic-cnns/1409-vgg","legacySlug":"1409-vgg","legacyPaths":[],"title":"VGG","subtitle":"Deep and More Deep","author":"Z. Yuan","paperDate":"2014-09-04","publishedOn":"2024-07-11","paperTitle":"Very Deep Convolutional Networks for Large-Scale Image Recognition","paperUrl":"https://arxiv.org/abs/1409.1556","bibliography":{"title":"Very Deep Convolutional Networks for Large-Scale Image Recognition","authors":["Karen Simonyan","Andrew Zisserman"],"url":"https://arxiv.org/abs/1409.1556","pdfUrl":"https://arxiv.org/pdf/1409.1556","codeUrl":null,"preprint":{"id":"1409.1556","submittedOn":"2014-09-04","url":"https://arxiv.org/abs/1409.1556"},"publication":{"venue":"ICLR","year":2015,"kind":"conference","url":"https://arxiv.org/pdf/1409.1556"},"citation":"@misc{classiccnnsvgg2014,\n  title = {{Very Deep Convolutional Networks for Large-Scale Image Recognition}},\n  author = {Karen Simonyan and Andrew Zisserman},\n  year = {2014},\n  eprint = {1409.1556},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1409.1556}\n}\n","citationPath":"/content/papers/citations/classic-cnns/vgg.6d704fc68256.bib"},"thumbnail":{"src":"/content/papers/assets/f8c8263e4970f0d994107c8084552e778e2f8f3cee14e213551fb6b0942568c2.jpg","width":968,"height":980},"locale":"en","path":"/content/papers/en/classic-cnns/vgg.2ffb2f474c3a.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"problem-solving","text":"Problem Solving","depth":2},{"id":"network-architecture","text":"Network Architecture","depth":3},{"id":"training-details","text":"Training Details","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"lrn-contribution","text":"LRN Contribution","depth":3},{"id":"performance-on-imagenet","text":"Performance on ImageNet","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"classic-cnns/alexnet","relation":"background","topic":"Training deeper convolutional networks"},{"id":"classic-cnns/resnet","relation":"next","topic":"Training deeper convolutional networks"},{"id":"reparameterization/vanillanet","relation":"next","topic":"Simplifying convolutional network design"}]}],"text":"The study of neural networks began long before AlexNet made its mark.\n\nAlexNet was an important milestone, with remarkable results in the 2012 ImageNet challenge.\n\n## Defining the Problem\n\nBy this time, the application of convolutional networks was beginning to show promise.\n\nBefore AlexNet, LeNet-5 successfully utilized Convolutional Neural Networks (CNNs) to tackle the problem of handwritten digit recognition.\n\n- [**Gradient-Based Learning Applied to Document Recognition**](http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf)\n\nAdditionally, this architecture had already been applied to small-scale datasets such as CIFAR-10 and MNIST.\n\nCompared to traditional feedforward neural networks (fully connected neural networks), CNNs benefited from their inductive bias, providing powerful learning capabilities for image data. Their structure effectively captured spatial dependencies and statistical regularities in images, and required far fewer parameters, making them easier to train.\n\nDespite the attractive features of CNNs, large-scale applications on high-resolution images were still very expensive.\n\nAs luck would have it, NVIDIA was there too. Two GTX 580 GPUs with 3 GB of memory each, combined with optimized 2D convolutions, provided enough compute to train this large CNN.\n\nFinally, the issue of large-scale datasets was addressed.\n\nThe large-scale image dataset ImageNet, introduced in 2009, provided enough labeled examples to effectively train these models while augmentation and regularization remained necessary to control overfitting.\n\n＊\n\nWith algorithms, data, and computational power in place, the next question was: how to design a deeper and larger CNN to improve image recognition performance?\n\n## Solving the Problem\n\n### Model Architecture\n\n![AlexNet paper Figure 2: five convolutional layers, three fully connected layers and the two-GPU connections](/content/papers/assets/87a5a48ff82989d4d78cc4d47a083f292fd7e249c1880c00ac4b31d8a042650d.jpg)\n\n*Paper Figure 2: the upper and lower halves run on different GPUs. The third convolution receives features from both cards; specified other layers connect only to the same card. Each 2048-neuron half belongs to one GPU.*\n\nAlexNet utilized a deep convolutional neural network with 5 convolutional layers and 3 fully connected layers.\n\nThis architecture influenced CNN research for years afterward; many later designs developed from this foundation.\n\n\n> [!TIP]\n> \n> CNN design had not yet settled into a standard pattern. Later conventions such as staged downsampling and Batch Normalization were not part of this model's usual toolkit.\n\n\n### ReLU Activation Function\n\nAlexNet uses ReLU instead of the then-common sigmoid or tanh. In the paper's Figure 1, a **different four-layer CNN** reached 25% CIFAR-10 training error about **six times faster** with ReLU than with tanh. That result is specific to this training comparison, not a measured sixfold speedup of AlexNet itself. ReLU avoids saturation on its positive side but does not eliminate every gradient problem.\n\nThe formula is: $f(x) = \\max(0, x)$.\n\nMeaning: when the input is greater than 0, the output equals the input; when the input is less than 0, the output is 0.\n\n$$ f(x) = \\begin{cases} x, & \\text{if } x > 0 \\\\ 0, & \\text{otherwise} \\end{cases} $$\n\n### Multi-GPU Training\n\nWhy does the AlexNet diagram look cut in half?\n\nThat is how the original paper draws it. The second, fourth and fifth convolutions connect only to features on the same GPU; the third receives features from both GPUs, and fully connected layers see all units in the preceding layer. These are not two independent CNNs. Relative to a narrower one-GPU comparison model, the two-GPU network reduced top-1 and top-5 error by **1.7 and 1.2 percentage points**, respectively; the two networks did not have exactly equal capacity.\n\n### Local Response Normalization\n\nBefore Batch Normalization, the authors used LRN to improve generalization. ReLU itself does not require normalization to avoid saturation on its positive branch.\n\nThe basic idea of LRN is to normalize each neuron's activation value by considering the activations in neighboring channels at the same spatial position, thereby suppressing overly active neurons and promoting competition among neurons.\n\nThis mechanism, similar to lateral inhibition in biological neurons, offers an analogy for competition across channels, rather than a guarantee that every neuron will remain active.\n\nIn AlexNet, LRN is defined as follows:\n\nGiven a neuron's activation value $a^i_{x,y}$ at position $(x, y)$, obtained by applying the $i$-th convolutional kernel and ReLU nonlinearity, the normalized activation value $b^i_{x,y}$ is calculated as:\n\n$$b^i_{x,y} = \\dfrac{a^i_{x,y}}{\\left(k + \\alpha \\sum_{j=\\max(0, i - \\lfloor n/2\\rfloor)}^{\\min(N-1, i + \\lfloor n/2\\rfloor)} (a^j_{x,y})^2 \\right)^\\beta}$$\n\nThe parameters are:\n\n- $a^i_{x,y}$: activation value at position $(x, y)$ after applying the $i$-th convolutional kernel and ReLU.\n- $b^i_{x,y}$: normalized activation value.\n- $k$, $\\alpha$, $\\beta$, and $n$: hyperparameters, adjusted via validation set:\n  - $k = 2$\n  - $\\alpha = 10^{-4}$\n  - $\\beta = 0.75$\n  - $n = 5$\n- $N$: total number of convolutional kernels in that layer.\n- $j$: index of neighboring convolutional kernels in the range $[\\max(0, i - \\lfloor n/2\\rfloor), \\min(N-1, i + \\lfloor n/2\\rfloor)]$.\n\n### Overlapping Max Pooling\n\nIn AlexNet, the max-pooling layer has a size of 3x3 and a stride of 2.\n\nThis operation reduces the feature map width and height by roughly half, lowering computation.\n\nCompared with non-overlapping 2×2 pooling at stride 2 and the same output size, 3×3 overlapping pooling reduced top-1 and top-5 error by **0.4 and 0.3 percentage points**. The authors also observed slightly less overfitting during training.\n\n### Dropout\n\nDuring training, the authors noticed that the model tended to overfit. To address this, they introduced Dropout.\n\nDropout randomly drops (sets to zero) some neurons during each training iteration.\n\nThis means the network computes with a randomly selected subset of neurons during each forward pass.\n\nDropped neurons do not contribute to forward propagation and are not updated during backpropagation.\n\nThis prevents the network from relying on specific neurons, reducing complex co-adaptation between neurons.\n\n\n> [!TIP]\n> \n> During inference, Dropout is turned off, and all neurons participate. The paper drops units without training-time rescaling and multiplies their outputs by 0.5 at test time. The PyTorch example below uses inverted dropout, which scales during training and needs no extra test-time factor.\n\n\n### Model Implementation\n\nLet's take a detailed look at the network composition:\n\n1. Input 224x224 image.\n2. First convolutional layer with 11x11 kernel size, stride 4, 96 feature maps, output size 55x55.\n3. Followed by max-pooling.\n4. Second convolutional layer with 5x5 kernel size, 256 feature maps, output size 27x27; it reads only the preceding features on the same GPU.\n5. Another max-pooling layer.\n6. Third convolutional layer with 3x3 kernel size, 384 feature maps, output size 13x13.\n7. Fourth convolutional layer with 3x3 kernel size, 384 feature maps, output size 13x13; it reads only the preceding features on the same GPU.\n8. Fifth convolutional layer with 3x3 kernel size, 256 feature maps, output size 13x13, with the same restricted connections.\n9. Finally, three fully connected layers: first with 4096 neurons, second with 4096 neurons, and the last with 1000 neurons corresponding to the 1000 classes in ImageNet.\n\nKey points from the paper:\n\n1. The five convolutional layers and first two fully connected layers use ReLU. The final layer produces logits; softmax converts them to class probabilities.\n2. Local Response Normalization is applied after the first and second convolutional layers.\n3. Max-pooling is applied after LRN and the fifth convolutional layer, with a size of 3x3 and stride of 2.\n4. Dropout is applied to the hidden activations of the first two fully connected layers with a dropout rate of 0.5.\n\nNow that the overall structure is clear, we can write a single-device model sketch. `groups=2` represents the paper's restricted connections. For a 224×224 input, the first convolution needs `padding=2` to produce 55×55; the final pooling output is 6×6.\n\n[PyTorch LRN](https://docs.pytorch.org/docs/2.14/generated/torch.nn.modules.normalization.LocalResponseNorm.html) multiplies the sum of squares by `alpha / size`, so `alpha=0.0005` here matches $10^{-4}$ in the formula above. The model returns logits for a loss such as `CrossEntropyLoss`. This is an architectural example, not the paper’s complete augmentation, initialization, and training procedure:\n\n```python\nimport torch.nn as nn\n\nclass AlexNet(nn.Module):\n\n    def __init__(self, num_classes=1000):\n        super(AlexNet, self).__init__()\n\n        self.stage1 = nn.Sequential(\n            nn.Conv2d(3, 96, kernel_size=11, stride=4, padding=2),\n            nn.ReLU(),\n            nn.LocalResponseNorm(size=5, alpha=0.0005, beta=0.75, k=2),\n            nn.MaxPool2d(kernel_size=3, stride=2)\n        )\n\n        self.stage2 = nn.Sequential(\n            nn.Conv2d(96, 256, kernel_size=5, padding=2, groups=2),\n            nn.ReLU(),\n            nn.LocalResponseNorm(size=5, alpha=0.0005, beta=0.75, k=2),\n            nn.MaxPool2d(kernel_size=3, stride=2)\n        )\n\n        self.stage3 = nn.Sequential(\n            nn.Conv2d(256, 384, kernel_size=3, padding=1),\n            nn.ReLU()\n        )\n\n        self.stage4 = nn.Sequential(\n            nn.Conv2d(384, 384, kernel_size=3, padding=1, groups=2),\n            nn.ReLU()\n        )\n\n        self.stage5 = nn.Sequential(\n            nn.Conv2d(384, 256, kernel_size=3, padding=1, groups=2),\n            nn.ReLU(),\n            nn.MaxPool2d(kernel_size=3, stride=2)\n        )\n\n        self.classifier = nn.Sequential(\n            nn.Flatten(),\n            nn.Linear(256 * 6 * 6, 4096),\n            nn.ReLU(),\n            nn.Dropout(0.5),\n            nn.Linear(4096, 4096),\n            nn.ReLU(),\n            nn.Dropout(0.5),\n            nn.Linear(4096, num_classes),\n        )\n\n    def forward(self, x):\n        x = self.stage1(x)\n        x = self.stage2(x)\n        x = self.stage3(x)\n        x = self.stage4(x)\n        x = self.stage5(x)\n        x = self.classifier(x)\n        return x\n```\n\n## Discussion\n\n### What Did the Convolutional Network Learn?\n\n![AlexNet paper Figure 3: all 96 first-layer 11×11×3 kernels, with GPU 1 above and GPU 2 below](/content/papers/assets/95f74c2777c8012a7f5424715bf224ec1fe784bf68912b7804c97a77326f3ebb.jpg)\n\n*Paper Figure 3: the 48 GPU 1 kernels respond largely to orientation and frequency; the 48 GPU 2 kernels are more color selective. This is a qualitative observation associated with the restricted cross-GPU connections.*\n\nThe authors visualized all **96** first-layer kernels. They learned features such as edges, color and texture. This image alone does not show which objects the later layers recognize.\n\nPreviously, such features were manually designed and fed to machine learning algorithms using techniques like SIFT, HOG, and Sobel operators.\n\nAfter AlexNet, the question was less about which features to design by hand and more about how to design a network that learns better features for itself.\n\n### ILSVRC-2010 Results\n\n| Model             | Top-1 | Top-5 |\n| ----------------- | ----- | ----- |\n| Sparse coding [2] | 47.1% | 28.2% |\n| SIFT + FVs [24]   | 45.7% | 25.7% |\n| CNN               | 37.5% | 17.0% |\n\nOn the ILSVRC-2010 dataset, the authors reported these test errors in their 2012 paper; this was not an entry in the 2010 competition:\n\n- **Top-1 error rate**: 37.5%\n- **Top-5 error rate**: 17.0%\n\nCompared to the best methods at the time:\n\n- **Sparse coding**: Top-1 error rate of 47.1%, Top-5 error rate of 28.2%.\n- **SIFT + Fisher Vectors (FVs)**: Top-1 error rate of 45.7%, Top-5 error rate of 25.7%.\n\nThis shows that AlexNet significantly outperformed other methods in ILSVRC-2010.\n\n### ILSVRC-2012 Results\n\n| Model          | Top-1 (val) | Top-5 (val) | Top-5 (test) |\n| -------------- | ----------- | ----------- | ------------ |\n| SIFT + FVs [7] | —           | —           | 26.2%        |\n| 1 CNN          | 40.7%       | 18.2%       | —            |\n| 5 CNNs         | 38.1%       | 16.4%       | 16.4%        |\n| 1 CNN\\*        | 39.0%       | 16.6%       | —            |\n| 7 CNNs\\*       | 36.7%       | 15.4%       | 15.3%        |\n\n- \\* indicates the use of additional ImageNet 2011 Fall pretraining; only the two added models in the 7 CNNs* ensemble use it.\n\nIn the ILSVRC-2012 competition, due to the unavailability of test set labels, the test error rates of all models could not be fully reported, but here are some key results:\n\n- A single CNN model achieved a Top-5 error rate of 18.2% on the validation set.\n- Averaging the predictions of five similar CNN models reduced the Top-5 error rate to 16.4%.\n- A CNN model with a sixth convolutional layer, pre-trained on the full ImageNet 2011 Fall release (15 million images and 22,000 classes), and fine-tuned on ILSVRC-2012, achieved a validation Top-5 error rate of 16.6%.\n- Averaging the predictions of two pre-trained CNN models with the previous five CNN models further reduced the test Top-5 error rate to 15.3%.\n\nThe second-place method, which averaged the predictions of multiple classifiers computed on different types of dense sampling features, achieved a Top-5 error rate of 26.2%.\n\n## Conclusion\n\nAlexNet achieved remarkable results in ILSVRC-2012, marking the rise of deep learning in computer vision. The **15.3%** top-5 test error came from an ensemble of seven models, two of which had extra ImageNet 2011 Fall pretraining; the single model had **18.2%** top-5 validation error.\n\nIts network design and training method had a lasting influence on deep learning research.\n","imageSizes":{"/content/papers/assets/87a5a48ff82989d4d78cc4d47a083f292fd7e249c1880c00ac4b31d8a042650d.jpg":{"width":1630,"height":570},"/content/papers/assets/95f74c2777c8012a7f5424715bf224ec1fe784bf68912b7804c97a77326f3ebb.jpg":{"width":1124,"height":480}}}
