コード例 #1
0
    def forward(self, x):
        outs = []

        if self.out1 > 0:
            h1 = self.conv1(x)
            h1 = self.conv1n(h1)
            h1 = relu.relu(h1)
            outs.append(h1)

        h3 = relu.relu(self.proj3n(self.proj3(x)))
        h3 = relu.relu(self.conv3n(self.conv3(h3)))
        outs.append(h3)

        h33 = relu.relu(self.proj33n(self.proj33(x)))
        h33 = relu.relu(self.conv33an(self.conv33a(h33)))
        h33 = relu.relu(self.conv33bn(self.conv33b(h33)))
        outs.append(h33)

        if self.pooltype == 'max':
            p = max_pooling_nd.max_pooling_2d(x, 3, stride=self.stride, pad=1,
                                              cover_all=False)
        else:
            p = average_pooling_2d.average_pooling_2d(x, 3, stride=self.stride,
                                                      pad=1)
        if self.proj_pool is not None:
            p = relu.relu(self.poolpn(self.poolp(p)))
        outs.append(p)

        y = concat.concat(outs, axis=1)
        return y
コード例 #2
0
 def functions(self):
     return collections.OrderedDict([
         ('conv1', [self.conv1, self.bn1, relu]),
         ('pool1', [lambda x: max_pooling_2d(x, ksize=3, stride=2)]),
         ('res2', [self.res2]),
         ('res3', [self.res3]),
         ('res4', [self.res4]),
         ('res5', [self.res5]),
         ('pool5', [_global_average_pooling_2d]),
         ('fc6', [self.fc6]),
         ('prob', [softmax]),
     ])
コード例 #3
0
    def forward(self, x):
        """Computes the output of the Inception module.

        Args:
            x (~chainer.Variable): Input variable.

        Returns:
            ~chainer.Variable: Output variable. Its array has the same spatial
            size and the same minibatch size as the input array. The channel
            dimension has size ``out1 + out3 + out5 + proj_pool``.

        """
        out1 = self.conv1(x)
        out3 = self.conv3(relu.relu(self.proj3(x)))
        out5 = self.conv5(relu.relu(self.proj5(x)))
        pool = self.projp(max_pooling_nd.max_pooling_2d(x, 3, stride=1, pad=1))
        y = relu.relu(concat.concat((out1, out3, out5, pool), axis=1))
        return y
コード例 #4
0
def _max_pooling_2d(x):
    return max_pooling_2d(x, ksize=2)