2 from chainer
import cuda
3 import chainer.functions
as F
4 import chainer.links
as L
5 from chainer
import Variable
6 from distutils.version
import LooseVersion
12 super(VGG_CNN_M_1024, self).
__init__(
13 conv1=L.Convolution2D(3, 96, ksize=7, stride=2),
14 conv2=L.Convolution2D(96, 256, ksize=5, stride=2, pad=1),
15 conv3=L.Convolution2D(256, 512, ksize=3, stride=1, pad=1),
16 conv4=L.Convolution2D(512, 512, ksize=3, stride=1, pad=1),
17 conv5=L.Convolution2D(512, 512, ksize=3, stride=1, pad=1),
18 fc6=L.Linear(18432, 4096),
19 fc7=L.Linear(4096, 1024),
20 cls_score=L.Linear(1024, n_class),
21 bbox_pred=L.Linear(1024, 4 * n_class)
29 h = F.local_response_normalization(h, n=5, k=2, alpha=5e-4, beta=.75)
30 h = F.max_pooling_2d(h, ksize=3, stride=2)
34 h = F.local_response_normalization(h, n=5, k=2, alpha=5e-4, beta=.75)
35 h = F.max_pooling_2d(h, ksize=3, stride=2)
46 h = F.roi_pooling_2d(h, rois, 6, 6, spatial_scale=0.0625)
50 h = F.dropout(h, ratio=.5)
54 h = F.dropout(h, ratio=.5)
56 h_cls_score = self.cls_score(h)
57 cls_score = F.softmax(h_cls_score)
58 bbox_pred = self.bbox_pred(h)
61 assert not chainer.config.train
62 return cls_score, bbox_pred
65 self.
cls_loss = F.softmax_cross_entropy(h_cls_score, t_cls)
66 self.
bbox_loss = F.smooth_l1_loss(bbox_pred, t_bbox)
68 xp = cuda.get_array_module(x.data)
69 lambda_ = (0.5 * (t_cls.data != self.
bg_label)).astype(xp.float32)
def __init__(self, n_class=21, bg_label=-1)
def __call__(self, x, rois, t=None)