当前位置: 首页>>代码示例>>Python>>正文


Python functions.average_pooling_2d方法代码示例

本文整理汇总了Python中chainer.functions.average_pooling_2d方法的典型用法代码示例。如果您正苦于以下问题:Python functions.average_pooling_2d方法的具体用法?Python functions.average_pooling_2d怎么用?Python functions.average_pooling_2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainer.functions的用法示例。


在下文中一共展示了functions.average_pooling_2d方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: forward

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_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

示例2: __call__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __call__(self, x):
        y = self.branches(x)

        u = F.sum(y, axis=1)
        s = F.average_pooling_2d(u, ksize=u.shape[2:])
        z = self.fc1(s)
        w = self.fc2(z)

        batch = w.shape[0]
        w = F.reshape(w, shape=(batch, self.num_branches, self.out_channels))
        w = self.softmax(w)
        w = F.expand_dims(F.expand_dims(w, axis=3), axis=4)

        y = y * w
        y = F.sum(y, axis=1)
        return y 
开发者ID:osmr,项目名称:imgclsmob,代码行数:18,代码来源:sknet.py

示例3: __init__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __init__(self,
                 in_channels,
                 out_channels,
                 stride,
                 dilate=1,
                 **kwargs):
        super(ResADownBlock, self).__init__(**kwargs)
        with self.init_scope():
            # self.pool = partial(
            #     F.average_pooling_2d,
            #     ksize=(stride if dilate == 1 else 1),
            #     stride=(stride if dilate == 1 else 1))
            self.pool = partial(
                F.average_pooling_nd,
                ksize=(stride if dilate == 1 else 1),
                stride=(stride if dilate == 1 else 1),
                pad_value=None)
            self.conv = conv1x1_block(
                in_channels=in_channels,
                out_channels=out_channels,
                activation=None) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:23,代码来源:resneta.py

示例4: __init__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __init__(self,
                 in_channels,
                 out_channels,
                 stride):
        super(ShakeShakeShortcut, self).__init__()
        assert (out_channels % 2 == 0)
        mid_channels = out_channels // 2

        with self.init_scope():
            self.pool = partial(
                F.average_pooling_2d,
                ksize=1,
                stride=stride)
            self.conv1 = conv1x1(
                in_channels=in_channels,
                out_channels=mid_channels)
            self.conv2 = conv1x1(
                in_channels=in_channels,
                out_channels=mid_channels)
            self.bn = L.BatchNormalization(
                size=out_channels,
                eps=1e-5) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:24,代码来源:shakeshakeresnet_cifar.py

示例5: __init__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __init__(self,
                 in_channels,
                 out_channels,
                 stride,
                 binarized=False):
        super(PreResUnit1bit, self).__init__()
        self.resize_identity = (stride != 1)

        with self.init_scope():
            self.body = PreResBlock1bit(
                in_channels=in_channels,
                out_channels=out_channels,
                stride=stride,
                binarized=binarized)
            if self.resize_identity:
                self.identity_pool = partial(
                    F.average_pooling_2d,
                    ksize=3,
                    stride=2,
                    pad=1) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:22,代码来源:wrn1bit_cifar.py

示例6: _downsample

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def _downsample(x):
    return F.average_pooling_2d(x, 2) 
开发者ID:pstuvwx,项目名称:Deep_VoiceChanger,代码行数:4,代码来源:block.py

示例7: _downsample_frq

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def _downsample_frq(x):
    return F.average_pooling_2d(x, (1,2)) 
开发者ID:pstuvwx,项目名称:Deep_VoiceChanger,代码行数:4,代码来源:block.py

示例8: __call__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __call__(self, x, v):
        out = super().__call__(x, v)
        out = cf.average_pooling_2d(out, self.r_size)
        return out 
开发者ID:musyoku,项目名称:chainer-gqn,代码行数:6,代码来源:representation.py

示例9: downscale2x

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def downscale2x(h):
    return F.average_pooling_2d(h, 2, 2, 0) 
开发者ID:pfnet-research,项目名称:chainer-stylegan,代码行数:4,代码来源:rescale.py

示例10: __call__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __call__(self, x):
        return F.average_pooling_2d(x, self.ksize, self.stride, self.pad) 
开发者ID:pfnet-research,项目名称:chainer-stylegan,代码行数:4,代码来源:auxiliary_links.py

示例11: global_average_pooling_2d

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def global_average_pooling_2d(x, use_cudnn=True):
    """Spatial global average pooling function.

    Args:
        x (~chainer.Variable): Input variable.
        use_cudnn (bool): If ``True`` and cuDNN is enabled, then this function
            uses cuDNN as the core implementation.
    """

    return F.average_pooling_2d(x, ksize=(x.shape[2], x.shape[3]), use_cudnn=use_cudnn) 
开发者ID:oyam,项目名称:Semantic-Segmentation-using-Adversarial-Networks,代码行数:12,代码来源:functions.py

示例12: forward

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_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)
        # chainer.report({'loss': loss, 'accuracy': F.accuracy(h, t)}, self)
        return loss

# from https://github.com/chainer/chainer/blob/master/examples/imagenet/resnet50.py 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:17,代码来源:Resnet_with_loss.py

示例13: forward

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def forward(self, x):
        y1 = F.average_pooling_2d(x, (1, 3), stride=(1, 4))
        return y1 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:5,代码来源:AveragePool2d.py

示例14: forward

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def forward(self, x):
        y1 = F.average_pooling_2d(x, 1, stride=2)
        return y1 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:5,代码来源:AveragePool2d.py

示例15: __init__

# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import average_pooling_2d [as 别名]
def __init__(self,
                 channels,
                 init_block_channels,
                 in_channels=3,
                 in_size=(224, 224),
                 classes=1000):
        super(SKNet, self).__init__()
        self.in_size = in_size
        self.classes = classes

        with self.init_scope():
            self.features = SimpleSequential()
            with self.features.init_scope():
                setattr(self.features, "init_block", ResInitBlock(
                    in_channels=in_channels,
                    out_channels=init_block_channels))
                in_channels = init_block_channels
                for i, channels_per_stage in enumerate(channels):
                    stage = SimpleSequential()
                    with stage.init_scope():
                        for j, out_channels in enumerate(channels_per_stage):
                            stride = 2 if (j == 0) and (i != 0) else 1
                            setattr(stage, "unit{}".format(j + 1), SKNetUnit(
                                in_channels=in_channels,
                                out_channels=out_channels,
                                stride=stride))
                            in_channels = out_channels
                    setattr(self.features, "stage{}".format(i + 1), stage)
                setattr(self.features, "final_pool", partial(
                    F.average_pooling_2d,
                    ksize=7,
                    stride=1))

            self.output = SimpleSequential()
            with self.output.init_scope():
                setattr(self.output, "flatten", partial(
                    F.reshape,
                    shape=(-1, in_channels)))
                setattr(self.output, "fc", L.Linear(
                    in_size=in_channels,
                    out_size=classes)) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:43,代码来源:sknet.py


注:本文中的chainer.functions.average_pooling_2d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。