CNN Alexnet
12기 이세윤
AlexNet
Local Response Normarlization
Dropout (비율 0.5)
Stochastic Gradient Descent Optimizer
In [1]:
from google.colab import drive
drive.mount('/content/drive')Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly
Enter your authorization code:
··········
Mounted at /content/drivePytorch
import torch.nn as nn
import torch.utils.model_zoo as model_zooclass AlexNet(nn.Module):
def __init__(self, num_classes=1000):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
## [Layer 1] Convolution
# Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0)
nn.Conv2d(3, 96, kernel_size=11, stride=4, padding=0),
nn.ReLU(inplace=True),
nn.LocalResponseNorm(size=5, alpha=0.0001, beta=0.75),
## [Layer 2] Max Pooling
nn.MaxPool2d(kernel_size=3, stride=2),
## [Layer 3] Convolution
nn.Conv2d(96, 256, kernel_size=5, stride=1, padding=2),
nn.ReLU(inplace=True),
nn.LocalResponseNorm(size=5, alpha=0.0001, beta=0.75),
## [Layer 4] Max Pooling
nn.MaxPool2d(kernel_size=3, stride=2),
## [Layer 5] Convolution
nn.Conv2d(256, 384, kernel_size=3, stride=1, padding=1),
nn.ReLU(inplace=True),
## [Layer 6] Convolution
nn.Conv2d(384, 384, kernel_size=3, stride=1, padding=1),
nn.ReLU(inplace=True),
## [Layer 7] Convolution
nn.Conv2d(384, 256, kernel_size=3, stride=1, padding=1),
nn.ReLU(inplace=True),
## [Layer 8] Max Pooling
nn.MaxPool2d(kernel_size=3, stride=2),
)
self.classifier = nn.Sequential(
## [Layer 9] Fully Connected Layer
nn.Dropout(),
nn.Linear(256 * 6 * 6, 4096),
nn.ReLU(inplace=True),
## [Layer 10] Fully Connected Layer
nn.Dropout(),
nn.Linear(4096, 4096),
nn.ReLU(inplace=True),
## [Layer 11] Fully Connected Layer
nn.Linear(4096, num_classes),
)
def forward(self, x):
x = self.features(x)
x = x.view(x.size(0), 256 * 6 * 6)
x = self.classifier(x)
return xIn [4]:
Keras
In [5]:
In [7]:
In [ ]:
In [9]:
MNIST Data에 적용해보기
In [ ]:
In [11]:
In [12]:
In [ ]:
In [ ]:
In [15]:
In [16]:
In [17]:
Out[17]:
In [18]:

Test Accuracy 0.9855로 꽤 좋은 성능을 보이고 있네요!!
Last updated
Was this helpful?