Skip to content

Instantly share code, notes, and snippets.

@jimexist
Created July 27, 2021 14:03
Show Gist options
  • Save jimexist/a3d361c7e8e23796841730772e24b363 to your computer and use it in GitHub Desktop.
Save jimexist/a3d361c7e8e23796841730772e24b363 to your computer and use it in GitHub Desktop.
Torch Vision AlexNet Model
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "d61a6c41",
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"import torchvision"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "abe6863d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('1.9.0', '0.10.0')"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torch.__version__, torchvision.__version__"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "1b55aad8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AlexNet(\n",
" (features): Sequential(\n",
" (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))\n",
" (1): ReLU(inplace=True)\n",
" (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
" (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))\n",
" (4): ReLU(inplace=True)\n",
" (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
" (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (7): ReLU(inplace=True)\n",
" (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (9): ReLU(inplace=True)\n",
" (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (11): ReLU(inplace=True)\n",
" (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
" )\n",
" (avgpool): AdaptiveAvgPool2d(output_size=(6, 6))\n",
" (classifier): Sequential(\n",
" (0): Dropout(p=0.5, inplace=False)\n",
" (1): Linear(in_features=9216, out_features=4096, bias=True)\n",
" (2): ReLU(inplace=True)\n",
" (3): Dropout(p=0.5, inplace=False)\n",
" (4): Linear(in_features=4096, out_features=4096, bias=True)\n",
" (5): ReLU(inplace=True)\n",
" (6): Linear(in_features=4096, out_features=1000, bias=True)\n",
" )\n",
")"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torchvision.models.AlexNet()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c7437d1d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment