alexnet.py
Go to the documentation of this file.
00001 import chainer
00002 import chainer.functions as F
00003 import chainer.links as L
00004 
00005 
00006 class AlexNet(chainer.Chain):
00007 
00008     def __init__(self, n_class=1000):
00009         super(AlexNet, self).__init__(
00010             conv1=L.Convolution2D(3,  96, 11, stride=4),
00011             conv2=L.Convolution2D(96, 256,  5, pad=2),
00012             conv3=L.Convolution2D(256, 384,  3, pad=1),
00013             conv4=L.Convolution2D(384, 384,  3, pad=1),
00014             conv5=L.Convolution2D(384, 256,  3, pad=1),
00015             fc6=L.Linear(9216, 4096),
00016             fc7=L.Linear(4096, 4096),
00017             fc8=L.Linear(4096, n_class))
00018 
00019     def __call__(self, x, t=None):
00020         h = F.local_response_normalization(self.conv1(x))
00021         h = F.max_pooling_2d(F.relu(h), 3, stride=2)
00022         h = F.local_response_normalization(self.conv2(h))
00023         h = F.max_pooling_2d(F.relu(h), 3, stride=2)
00024         h = F.relu(self.conv3(h))
00025         h = F.relu(self.conv4(h))
00026         h = F.max_pooling_2d(F.relu(self.conv5(h)), 3, stride=2)
00027         h = F.dropout(F.relu(self.fc6(h)))
00028         h = F.dropout(F.relu(self.fc7(h)))
00029         h = self.fc8(h)
00030 
00031         self.pred = F.softmax(h)
00032         if t is None:
00033             assert not chainer.config.train
00034             return
00035 
00036         self.loss = F.softmax_cross_entropy(h, t)
00037         self.accuracy = F.accuracy(h, t)
00038         return self.loss


jsk_recognition_utils
Author(s):
autogenerated on Sun Oct 8 2017 02:42:48