5 import chainer.functions
as F
6 import chainer.links
as L
11 def __init__(self, in_size, ch, out_size, stride=2):
12 initialW = chainer.initializers.HeNormal()
14 conv1=L.Convolution2D(
15 in_size, ch, 1, stride, 0, nobias=
True, initialW=initialW),
16 bn1=L.BatchNormalization(ch),
17 conv2=L.Convolution2D(
18 ch, ch, 3, 1, 1, nobias=
True, initialW=initialW),
19 bn2=L.BatchNormalization(ch),
20 conv3=L.Convolution2D(
21 ch, out_size, 1, 1, 0, nobias=
True, initialW=initialW),
22 bn3=L.BatchNormalization(out_size),
24 conv4=L.Convolution2D(
25 in_size, out_size, 1, stride, 0,
26 nobias=
True, initialW=initialW),
27 bn4=L.BatchNormalization(out_size),
31 h1 = F.relu(self.bn1(self.conv1(x)))
32 h1 = F.relu(self.bn2(self.conv2(h1)))
33 h1 = self.bn3(self.conv3(h1))
34 h2 = self.bn4(self.conv4(x))
36 return F.relu(h1 + h2)
42 initialW = chainer.initializers.HeNormal()
44 conv1=L.Convolution2D(
45 in_size, ch, 1, 1, 0, nobias=
True, initialW=initialW),
46 bn1=L.BatchNormalization(ch),
47 conv2=L.Convolution2D(
48 ch, ch, 3, 1, 1, nobias=
True, initialW=initialW),
49 bn2=L.BatchNormalization(ch),
50 conv3=L.Convolution2D(
51 ch, in_size, 1, 1, 0, nobias=
True, initialW=initialW),
52 bn3=L.BatchNormalization(in_size),
56 h = F.relu(self.bn1(self.conv1(x)))
57 h = F.relu(self.bn2(self.conv2(h)))
58 h = self.bn3(self.conv3(h))
65 def __init__(self, layer, in_size, ch, out_size, stride=2):
67 links = [(
'a',
BottleNeckA(in_size, ch, out_size, stride))]
68 for i
in range(layer - 1):
77 f = getattr(self, name)
88 initialW = chainer.initializers.HeNormal()
90 conv1=L.Convolution2D(
91 3, 64, 7, 2, 3, nobias=
True, initialW=initialW),
92 bn1=L.BatchNormalization(64),
93 res2=
Block(3, 64, 64, 256, 1),
94 res3=
Block(4, 256, 128, 512),
95 res4=
Block(23, 512, 256, 1024),
96 res5=
Block(3, 1024, 512, 2048),
97 fc=L.Linear(2048, 1000),
106 h = self.bn1(self.conv1(x))
107 h = F.max_pooling_2d(F.relu(h), 3, stride=2)
112 h = F.average_pooling_2d(h, 7, stride=1)
118 self.
loss = F.softmax_cross_entropy(h, t)
126 h = self.bn1(self.conv1(x))
127 h = F.max_pooling_2d(F.relu(h), 3, stride=2)
132 h = F.average_pooling_2d(h, 7, stride=1)
def __init__(self, layer, in_size, ch, out_size, stride=2)
def __init__(self, in_size, ch, out_size, stride=2)
def __call__(self, x, t=None)
def __init__(self, in_size, ch)