<jupyter_start><jupyter_text>AlexNet[paper](https://arxiv.org/abs/1404.5997)<jupyter_code>#@title Install PyTorch
!pip install pytorch torchvision<jupyter_output>Collecting pytorch
  Downloading https://files.pythonhosted.org/packages/a9/41/4487bc23e3ac4d674943176f5aa309427b011e00607eb98899e9d951f67b/pytorch-0.1.2.tar.gz
Requirement already satisfied: torchvision in /usr/local/lib/python3.6/dist-packages (0.2.1)
Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from torchvision) (1.0.1.post2)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from torchvision) (1.11.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torchvision) (1.14.6)
Collecting pillow>=4.1.1 (from torchvision)
[?25l  Downloading https://files.pythonhosted.org/packages/85/5e/e91792f198bbc5a0d7d3055ad552bc4062942d27eaf75c3e2783cf64eae5/Pillow-5.4.1-cp36-cp36m-manylinux1_x86_64.whl (2.0MB)
[K    100% |████████████████████████████████| 2.0MB 11.1MB/s 
[?25hBuilding wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... [?25lerror
[31m  Failed building w[...]<jupyter_text>Import<jupyter_code>import numpy

import torch
from torch import nn
from torch.utils import model_zoo<jupyter_output><empty_output><jupyter_text>Network<jupyter_code>class AlexNet(nn.Module):
    
    def __init__(self, num_classes=1000):
        super().__init__()
        self.conv = nn.Sequential(
            nn.Conv2d(in_channels=3, out_channels=64, kernel_size=11, stride=4, padding=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(64, 192, kernel_size=5, padding=2),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
            nn.Conv2d(192, 384, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(384, 256, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.Conv2d(256, 256, kernel_size=3, padding=1),
            nn.ReLU(inplace=True),
            nn.MaxPool2d(kernel_size=3, stride=2),
        )
        self.avgpool = nn.AdaptiveAvgPool2d((6, 6))
        self.fc = nn.Sequential(
            nn.Dropout(),
            nn.Linear(256*6*6, 4096),
            nn.ReLU(inplace=True),
            nn.Dropout(),
            nn.Linear(4096, 4096),
            nn.ReLU(inplace=True),
            nn.Linear(4096, num_classes),
        )
        
        
    def forward(self, x):
        x = self.conv(x)
        x = self.avgpool(x)
        x = x.view(x.shape(0), 256*6*6)
        x = self.fc(x)
        
        return x
model = AlexNet()<jupyter_output><empty_output><jupyter_text>Load pre-trained model's weight<jupyter_code>model_path = 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth'

model.load_state_dict(
    model_zoo.load_url(model_path),
    strict=False
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14213197969543148, 'fraction_numerical': 0.08223350253807106, 'mean_word_length': 3.2593659942363113, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '522530', 'license': 'MIT', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1125, 'n_words': 160, 'path': 'alexnet.ipynb', 'repo_name': 'abhiWriteCode/dl_models', 'size': '2955'}