当前位置: 首页>>代码示例>>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;未经允许,请勿转载。