當前位置: 首頁>>代碼示例>>Python>>正文


Python functions.max_pooling_2d方法代碼示例

本文整理匯總了Python中chainer.functions.max_pooling_2d方法的典型用法代碼示例。如果您正苦於以下問題:Python functions.max_pooling_2d方法的具體用法?Python functions.max_pooling_2d怎麽用?Python functions.max_pooling_2d使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chainer.functions的用法示例。


在下文中一共展示了functions.max_pooling_2d方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __call__(self, x, t):
        h = F.relu(self.conv1_1(x))
        h = F.relu(self.conv1_2(h))
        h = F.max_pooling_2d(h, 2, 2)
        h = F.relu(self.conv2_1(h))
        h = F.relu(self.conv2_2(h))
        h = F.max_pooling_2d(h, 2, 2)
        h = F.relu(self.conv3_1(h))
        h = F.relu(self.conv3_2(h))
        h = F.relu(self.conv3_3(h))
        h = F.max_pooling_2d(h, 2, 2)
        h = F.relu(self.conv4_1(h))
        h = F.relu(self.conv4_2(h))
        h = F.relu(self.conv4_3(h))
        h = F.max_pooling_2d(h, 2, 2)
        h = F.relu(self.conv5_1(h))
        h = F.relu(self.conv5_2(h))
        h = F.relu(self.conv5_3(h))
        h = F.max_pooling_2d(h, 2, 2)
        h = F.dropout(F.relu(self.fc6(h)), ratio=0.5, train=self.train)
        h = F.dropout(F.relu(self.fc7(h)), ratio=0.5, train=self.train)
        h = self.score_fr(h)
        h = self.upsample(h)

        return h 
開發者ID:mitmul,項目名稱:ssai-cnn,代碼行數:27,代碼來源:FCN_32s.py

示例2: __call__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __call__(self, x, t):
        h = F.relu(self.conv1(x))
        h = F.max_pooling_2d(h, 2, 1)
        h = F.relu(self.conv2(h))
        h = F.relu(self.conv3(h))
        h = F.dropout(F.relu(self.fc4(h)), train=self.train)
        h = self.fc5(h)
        h = F.reshape(h, (x.data.shape[0], 3, 16, 16))
        h = self.channelwise_inhibited(h)

        if self.train:
            self.loss = F.softmax_cross_entropy(h, t, normalize=False)
            return self.loss
        else:
            self.pred = F.softmax(h)
            return self.pred 
開發者ID:mitmul,項目名稱:ssai-cnn,代碼行數:18,代碼來源:MnihCNN_cis.py

示例3: __call__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __call__(self, x):
        h = F.relu(self.conv1_1(x))
        h = F.relu(self.conv1_2(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        h = F.relu(self.conv2_1(h))
        h = F.relu(self.conv2_2(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        h = F.relu(self.conv3_1(h))
        h = F.relu(self.conv3_2(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        h = F.relu(self.conv4_1(h))
        h = F.relu(self.conv4_2(h))
        h = F.spatial_pyramid_pooling_2d(h, 3, F.MaxPooling2D)
        h = F.tanh(self.fc4(h))
        h = F.dropout(h, ratio=.5, train=self.train)
        h = F.tanh(self.fc5(h))
        h = F.dropout(h, ratio=.5, train=self.train)
        h = self.fc6(h)
        return h 
開發者ID:oyam,項目名稱:Semantic-Segmentation-using-Adversarial-Networks,代碼行數:21,代碼來源:spp_discriminator.py

示例4: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x, t):
        # def forward(self, x):
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv1(x))), 3, stride=2)
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv2(h))), 3, stride=2)
        h = F.relu(self.conv3(h))
        h = F.relu(self.conv4(h))
        h = F.max_pooling_2d(F.relu(self.conv5(h)), 3, stride=2)
        h = F.dropout(F.relu(self.fc6(h)))
        h = F.dropout(F.relu(self.fc7(h)))
        h = self.fc8(h)

        loss = F.softmax_cross_entropy(h, t)
        #loss = h

        # chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self)
        return loss

# from https://github.com/chainer/chainer/blob/master/examples/imagenet/alex.py 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:22,代碼來源:Alex_with_loss.py

示例5: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x):
        """Computes the output of the Inception module.
        Args:
            x (~chainer.Variable): Input variable.
        Returns:
            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(F.max_pooling_2d(
            x, 3, stride=1, pad=1))

        y = relu.relu(concat.concat((out1, out3, out5, pool), axis=1))
        return y 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:19,代碼來源:GoogleNet_with_loss.py

示例6: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x):
        hs = self.base(x)

        with flags.for_unroll():
            for i in range(self.n_base_output_minus1, -1, -1):
                hs[i] = self.inner[i](hs[i])
                if i < self.n_base_output_minus1:
                    hs[i] += F.unpooling_2d(hs[i + 1], 2, cover_all=False)

            for i in range(self.n_base_output):
                hs[i] = self.outer[i](hs[i])

            for _ in range(self.scales_minus_n_base_output):
                hs.append(F.max_pooling_2d(hs[-1], 1, stride=2, cover_all=False))

        return hs


# ====================================== 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:21,代碼來源:fpn.py

示例7: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x, t):
        # def forward(self, x):
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv1(x))), 3, stride=2)
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv2(h))), 3, stride=2)
        h = F.relu(self.conv3(h))
        h = F.relu(self.conv4(h))
        h = F.max_pooling_2d(F.relu(self.conv5(h)), 3, stride=2)
        h = F.dropout(F.relu(self.fc6(h)))
        h = F.dropout(F.relu(self.fc7(h)))
        h = self.fc8(h)

        loss = F.softmax_cross_entropy(h, t)
        #loss = h

        # chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self)
        return loss 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:20,代碼來源:Alex.py

示例8: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x, t):
        h = self.bn1(self.conv1(x))
        h = F.max_pooling_2d(F.relu(h), 3, stride=2)
        h = self.res2(h)
        h = self.res3(h)
        h = self.res4(h)
        h = self.res5(h)
        h = F.average_pooling_2d(h, 7, stride=1)
        h = self.fc(h)

        #loss = F.softmax_cross_entropy(h, t)
        loss = self.softmax_cross_entropy(h, t)
        if self.compute_accuracy:
            chainer.report({'loss': loss, 'accuracy': F.accuracy(h, np.argmax(t, axis=1))}, self)
        else:
            chainer.report({'loss': loss}, self)
        return loss 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:19,代碼來源:resnet50.py

示例9: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def forward(self, x, t):
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv1(x))), 3, stride=2)
        h = F.max_pooling_2d(F.local_response_normalization(
            F.relu(self.conv2(h))), 3, stride=2)
        h = F.relu(self.conv3(h))
        h = F.relu(self.conv4(h))
        h = F.max_pooling_2d(F.relu(self.conv5(h)), 3, stride=2)
        h = F.dropout(F.relu(self.fc6(h)))
        h = F.dropout(F.relu(self.fc7(h)))
        h = self.fc8(h)

        # EDIT(hamaji): ONNX-chainer cannot output SoftmaxCrossEntropy.
        # loss = F.softmax_cross_entropy(h, t)
        loss = self.softmax_cross_entropy(h, t)
        if self.compute_accuracy:
            chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self)
        else:
            chainer.report({'loss': loss}, self)
        return loss 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:22,代碼來源:alex.py

示例10: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels,
                 ksize,
                 pad):
        super(DPNInitBlock, self).__init__()
        with self.init_scope():
            self.conv = L.Convolution2D(
                in_channels=in_channels,
                out_channels=out_channels,
                ksize=ksize,
                stride=2,
                pad=pad,
                nobias=True)
            self.bn = dpn_batch_norm(channels=out_channels)
            self.activ = F.relu
            self.pool = partial(
                F.max_pooling_2d,
                ksize=3,
                stride=2,
                pad=1,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:24,代碼來源:dpn.py

示例11: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels):
        super(WRNInitBlock, self).__init__()
        with self.init_scope():
            self.conv = WRNConv(
                in_channels=in_channels,
                out_channels=out_channels,
                ksize=7,
                stride=2,
                pad=3,
                activate=True)
            self.pool = partial(
                F.max_pooling_2d,
                ksize=3,
                stride=2,
                pad=1,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:20,代碼來源:wrn.py

示例12: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels):
        super(SEInitBlock, self).__init__()
        mid_channels = out_channels // 2

        with self.init_scope():
            self.conv1 = conv3x3_block(
                in_channels=in_channels,
                out_channels=mid_channels,
                stride=2)
            self.conv2 = conv3x3_block(
                in_channels=mid_channels,
                out_channels=mid_channels)
            self.conv3 = conv3x3_block(
                in_channels=mid_channels,
                out_channels=out_channels)
            self.pool = partial(
                F.max_pooling_2d,
                ksize=3,
                stride=2,
                pad=1,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:25,代碼來源:senet.py

示例13: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels_list):
        super(DownUnit, self).__init__()
        with self.init_scope():
            self.blocks = SimpleSequential()
            with self.blocks.init_scope():
                for i, out_channels in enumerate(out_channels_list):
                    setattr(self.blocks, "block{}".format(i + 1), FishBlock(
                        in_channels=in_channels,
                        out_channels=out_channels))
                    in_channels = out_channels
            self.pool = partial(
                F.max_pooling_2d,
                ksize=2,
                stride=2,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:19,代碼來源:fishnet.py

示例14: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels):
        super(PreResInitBlock, self).__init__()
        with self.init_scope():
            self.conv = L.Convolution2D(
                in_channels=in_channels,
                out_channels=out_channels,
                ksize=7,
                stride=2,
                pad=3,
                nobias=True)
            self.bn = L.BatchNormalization(size=out_channels)
            self.activ = F.relu
            self.pool = partial(
                F.max_pooling_2d,
                ksize=3,
                stride=2,
                pad=1,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:22,代碼來源:preresnet.py

示例15: __init__

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import max_pooling_2d [as 別名]
def __init__(self,
                 in_channels,
                 out_channels):
        super(AirInitBlock, self).__init__()
        mid_channels = out_channels // 2

        with self.init_scope():
            self.conv1 = conv3x3_block(
                in_channels=in_channels,
                out_channels=mid_channels,
                stride=2)
            self.conv2 = conv3x3_block(
                in_channels=mid_channels,
                out_channels=mid_channels)
            self.conv3 = conv3x3_block(
                in_channels=mid_channels,
                out_channels=out_channels)
            self.pool = partial(
                F.max_pooling_2d,
                ksize=3,
                stride=2,
                pad=1,
                cover_all=False) 
開發者ID:osmr,項目名稱:imgclsmob,代碼行數:25,代碼來源:airnet.py


注:本文中的chainer.functions.max_pooling_2d方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。