Created
March 28, 2020 08:37
-
-
Save n-taku/3be05c6ccc003aec8187f70bd783ed65 to your computer and use it in GitHub Desktop.
CIFIR10のモデルサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "CIFIR10_Model.ipynb", | |
"provenance": [] | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "tSRtq3pRRdf1", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 340 | |
}, | |
"outputId": "d5854ceb-fdd9-455f-d2f7-051e51ec377a" | |
}, | |
"source": [ | |
"import torch.nn as nn\n", | |
"import torch.nn.functional as F\n", | |
"from torchsummary import summary\n", | |
"\n", | |
"class Net(nn.Module):\n", | |
" def __init__(self):\n", | |
" super(Net, self).__init__()\n", | |
" self.conv1 = nn.Conv2d(3, 64, 5)\n", | |
" self.pool = nn.MaxPool2d(2, 2)\n", | |
" self.conv2 = nn.Conv2d(64, 128, 5)\n", | |
" self.fc1 = nn.Linear(128 * 5 * 5, 120)\n", | |
" self.fc2 = nn.Linear(120, 10)\n", | |
"\n", | |
" def forward(self, x):\n", | |
" x = self.pool(F.relu(self.conv1(x)))\n", | |
" x = self.pool(F.relu(self.conv2(x)))\n", | |
" x = x.view(-1, 128 * 5 * 5)\n", | |
" x = F.relu(self.fc1(x))\n", | |
" x = self.fc2(x)\n", | |
" return x\n", | |
"\n", | |
"summary(Net(), (3, 32, 32))" | |
], | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"----------------------------------------------------------------\n", | |
" Layer (type) Output Shape Param #\n", | |
"================================================================\n", | |
" Conv2d-1 [-1, 64, 28, 28] 4,864\n", | |
" MaxPool2d-2 [-1, 64, 14, 14] 0\n", | |
" Conv2d-3 [-1, 128, 10, 10] 204,928\n", | |
" MaxPool2d-4 [-1, 128, 5, 5] 0\n", | |
" Linear-5 [-1, 120] 384,120\n", | |
" Linear-6 [-1, 10] 1,210\n", | |
"================================================================\n", | |
"Total params: 595,122\n", | |
"Trainable params: 595,122\n", | |
"Non-trainable params: 0\n", | |
"----------------------------------------------------------------\n", | |
"Input size (MB): 0.01\n", | |
"Forward/backward pass size (MB): 0.60\n", | |
"Params size (MB): 2.27\n", | |
"Estimated Total Size (MB): 2.88\n", | |
"----------------------------------------------------------------\n" | |
], | |
"name": "stdout" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment