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


Python cntk.AVG_POOLING属性代码示例

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


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

示例1: pool2d

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def pool2d(x, pool_size, strides=(1, 1),
           padding='valid', data_format=None,
           pool_mode='max'):
    data_format = normalize_data_format(data_format)

    padding = _preprocess_border_mode(padding)
    strides = strides
    pool_size = pool_size
    x = _preprocess_conv2d_input(x, data_format)
    if pool_mode == 'max':
        x = C.pooling(
            x,
            C.MAX_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    elif pool_mode == 'avg':
        x = C.pooling(
            x,
            C.AVG_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    else:
        raise ValueError('Invalid pooling mode: ' + str(pool_mode))
    return _postprocess_conv2d_output(x, data_format) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:28,代码来源:cntk_backend.py

示例2: pool3d

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid',
           data_format=None, pool_mode='max'):
    data_format = normalize_data_format(data_format)

    padding = _preprocess_border_mode(padding)

    x = _preprocess_conv3d_input(x, data_format)

    if pool_mode == 'max':
        x = C.pooling(
            x,
            C.MAX_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    elif pool_mode == 'avg':
        x = C.pooling(
            x,
            C.AVG_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    else:
        raise ValueError('Invalid pooling mode: ' + str(pool_mode))

    return _postprocess_conv3d_output(x, data_format) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:28,代码来源:cntk_backend.py

示例3: emit_Pool

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def emit_Pool(self, IR_node):
        input_node = self.IR_graph.get_node(IR_node.in_edges[0]).real_variable_name
        if IR_node.layer.attr['global_pooling'].b:
            self.used_layers.add('GlobalPooling')
            code = "{:<15} = global_pooling({}, '{}', name = '{}')".format(
                IR_node.variable_name,
                input_node,
                IR_node.get_attr('pooling_type'),
                IR_node.name)
        else:
            for e in IR_node.get_attr('dilations', []):
                assert e == 1

            dim = len(IR_node.get_attr('kernel_shape')) - 2
            padding = not self.is_valid_padding(IR_node.get_attr('auto_pad'), IR_node.get_attr('pads'))
            padding = [False] + [padding] * dim
            ceil_out_dim = self.is_ceil_mode(IR_node.get_attr('pads'))

            pooling_type = IR_node.get_attr('pooling_type')
            if pooling_type == 'MAX':
                pooling_type = cntk.MAX_POOLING
            elif pooling_type == 'AVG':
                pooling_type = cntk.AVG_POOLING
            else:
                raise ValueError

            if self.weight_loaded:
                self.used_layers.add(IR_node.type)
                code = "{:<15} = pooling({}, pooling_type={}, pooling_window_shape={}, strides={}, auto_padding={}, ceil_out_dim={})".format(
                    IR_node.variable_name,
                    input_node,
                    pooling_type,
                    tuple(IR_node.get_attr('kernel_shape')[1:-1]),
                    tuple(IR_node.get_attr('strides')[1:-1]),
                    padding,
                    ceil_out_dim
                    )
            else:
                raise NotImplementedError
        return code 
开发者ID:microsoft,项目名称:MMdnn,代码行数:42,代码来源:cntk_emitter.py

示例4: rename_Pooling

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def rename_Pooling(self, source_node):
        IR_node = self._convert_identity_operation(source_node, new_op='Pool')
        dim = len(IR_node.attr['_output_shapes'].list.shape[0].dim)
        kwargs = {}

        # strides
        kwargs['strides'] = list(source_node.get_attr('strides')) + [1]
        if len(kwargs['strides']) < dim:
            kwargs['strides'] = [1] + kwargs['strides']

        # window_shape
        kwargs['kernel_shape'] = list(source_node.get_attr('poolingWindowShape')) + [1]
        if len(kwargs['kernel_shape']) < dim:
            kwargs['kernel_shape'] = [1] + kwargs['kernel_shape']

        # pool type
        pool_type = source_node.get_attr('poolingType')
        if pool_type == _cntk.MAX_POOLING:
            kwargs['pooling_type'] = 'MAX'
        elif pool_type == _cntk.AVG_POOLING:
            kwargs['pooling_type'] = 'AVG'
        else:
            raise ValueError("Unknown pooling type [{}].".format(pool_type))

        # padding
        padding = source_node.get_attr('autoPadding')
        if len(padding) >= dim - 1:
            padding = padding[1:]
        elif len(padding) < dim - 2:
            padding.extend([padding[-1]] * (dim - len(padding) - 2))
        for pad in padding:
            assert pad == padding[-1]
        kwargs['auto_pad'] = 'SAME_LOWER' if padding[0] else 'VALID'
        kwargs['pads'] = self._convert_padding_to_IR(kwargs['kernel_shape'][1:-1], padding)

        assign_IRnode_values(IR_node, kwargs) 
开发者ID:microsoft,项目名称:MMdnn,代码行数:38,代码来源:cntk_parser.py

示例5: pool2d

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def pool2d(x, pool_size, strides=(1, 1),
           padding='valid', data_format=None,
           pool_mode='max'):
    if data_format is None:
        data_format = image_data_format()
    if data_format not in {'channels_first', 'channels_last'}:
        raise ValueError('Unknown data_format ' + str(data_format))

    padding = _preprocess_border_mode(padding)
    strides = strides
    pool_size = pool_size
    x = _preprocess_conv2d_input(x, data_format)
    if pool_mode == 'max':
        x = C.pooling(
            x,
            C.MAX_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    elif pool_mode == 'avg':
        x = C.pooling(
            x,
            C.AVG_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    else:
        raise ValueError('Invalid pooling mode: ' + str(pool_mode))
    return _postprocess_conv2d_output(x, data_format) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:31,代码来源:cntk_backend.py

示例6: pool3d

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import AVG_POOLING [as 别名]
def pool3d(x, pool_size, strides=(1, 1, 1), padding='valid',
           data_format=None, pool_mode='max'):
    if data_format is None:
        data_format = image_data_format()
    if data_format not in {'channels_first', 'channels_last'}:
        raise ValueError('Unknown data_format ' + str(data_format))

    padding = _preprocess_border_mode(padding)

    x = _preprocess_conv3d_input(x, data_format)

    if pool_mode == 'max':
        x = C.pooling(
            x,
            C.MAX_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    elif pool_mode == 'avg':
        x = C.pooling(
            x,
            C.AVG_POOLING,
            pool_size,
            strides,
            auto_padding=[padding])
    else:
        raise ValueError('Invalid pooling mode: ' + str(pool_mode))

    return _postprocess_conv3d_output(x, data_format) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:31,代码来源:cntk_backend.py


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