• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common_graph.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mmdnn.conversion.caffe.common_graph.Node的典型用法代码示例。如果您正苦于以下问题:Python Node类的具体用法?Python Node怎么用?Python Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: map_crop

 def map_crop(cls, node):
     offset = node.parameters.offset
     if offset:
         kwargs = {'offset': int(node.parameters.offset[0])}
         return Node.create('crop', **kwargs)
     else:
         return Node.create('crop')
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:7,代码来源:mapper.py


示例2: map_convolution

 def map_convolution(cls, node):
     parent, _ = node.get_only_parent()
     kwargs = cls.get_kernel_params(node, parent.output_shape)
     kwargs['kernel_shape'] = [node.kernel_parameters.k_h, node.kernel_parameters.k_w, parent.output_shape.channels, node.parameters.num_output]
     kwargs['use_bias'] = node.parameters.bias_term
     kwargs['group'] = node.parameters.group
     return Node.create('Conv', **kwargs)
开发者ID:zbxzc35,项目名称:MMdnn,代码行数:7,代码来源:mapper.py


示例3: map_scale

 def map_scale(cls, node):
     raise NotImplementedError
     # TODO: The gamma parameter has to be set (in node.data?) and this should work.
     # Also, mean should be set to 0, and var to 1, just to be safe.
     scale_value = float(node.parameters.filler.value)
     kwargs = {'scale' : True, 'bias' : False, 'gamma' : scale_value, 'epsilon': 0}
     return Node.create('BatchNorm', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:7,代码来源:mapper.py


示例4: map_eltwise

 def map_eltwise(cls, node):
     operations = {0: 'Mul', 1: 'Add', 2: 'Max'}
     op_code = node.parameters.operation
     try:
         return Node.create(operations[op_code])
     except KeyError:
         raise ConversionError('Unknown elementwise operation: {}'.format(op_code))
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:7,代码来源:mapper.py


示例5: map_deconvolution

    def map_deconvolution(cls, node):
        raise NotImplementedError()
        parent, _ = node.get_only_parent()
        kwargs = cls.get_kernel_params(node, parent.output_shape)

        kwargs['kernel_shape'] = [node.kernel_parameters.k_h, node.kernel_parameters.k_w, parent.output_shape.channels, node.parameters.num_output]
        kwargs['group'] = node.parameters.group
        return Node.create('deconv', **kwargs)
开发者ID:zbxzc35,项目名称:MMdnn,代码行数:8,代码来源:mapper.py


示例6: _add_flatten_layer

    def _add_flatten_layer(cls, node):
        shape = TensorShape()
        dim = shape.dim.add()
        dim.size = -1

        dim = shape.dim.add()
        dim.size = 1
        for i in node.output_shape[1:]:
            dim.size *= i
        kwargs = {'_output_shapes' : [shape]}
        return Node.create('Flatten', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:11,代码来源:mapper.py


示例7: map_pooling

 def map_pooling(cls, node):
     parent, _ = node.get_only_parent()
     kwargs = cls.get_kernel_params(node, parent.output_shape)
     if node.parameters.pool == 0:
         kwargs['pooling_type'] = 'MAX'
     elif node.parameters.pool == 1:
         kwargs['pooling_type'] = 'AVG'
     else:
         # Stochastic pooling, for instance.
         raise ConversionError('Unsupported pooling type.')
     cls._convert_output_shape(kwargs, node)
     return Node.create('Pool', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:12,代码来源:mapper.py


示例8: map_deconvolution

    def map_deconvolution(cls, node):
        parent, _ = node.get_only_parent()
        kwargs = cls.get_kernel_params(node, parent.output_shape)

        kwargs['kernel_shape'] = [node.kernel_parameters.k_h, node.kernel_parameters.k_w, node.parameters.num_output, parent.output_shape.channels]
        kwargs['use_bias'] = node.parameters.bias_term
        if node.parameters.dilation:
            dilation = node.parameters.dilation[0]
            if dilation != 1:
                kwargs['dilations'] = [1, dilation, dilation, 1]
        kwargs['group'] = node.parameters.group
        return Node.create('ConvTranspose', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:12,代码来源:mapper.py


示例9: map_inner_product

    def map_inner_product(cls, node):
        #TODO: Axis
        assert node.parameters.axis == 1
        #TODO: Unbiased
        kwargs = {'use_bias' : node.parameters.bias_term, 'units' : node.parameters.num_output}

        # check if need the Flatten layer
        parent, _ = node.get_only_parent()
        ret = []

        # if parent.output_shape.height > 1 or parent.output_shape.width > 1:
        ret.append(cls._add_flatten_layer(parent))
        ret.append(Node.create('FullyConnected', **kwargs))
        return ret
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:14,代码来源:mapper.py


示例10: map_data

    def map_data(cls, node):
        # TODO: We need to identify whether this is 4D image data, otherwise we shouldn't change the dimension order
        shape = TensorShape()
        dim = shape.dim.add()
        dim.size = -1
        for i in node.output_shape[2:]:
            dim = shape.dim.add()
            dim.size = i
        dim = shape.dim.add()
        dim.size = node.output_shape.channels

        kwargs = {'shape': shape} # Ignore the dimension of batch size
        cls._convert_output_shape(kwargs, node)
        return Node.create('DataInput', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:14,代码来源:mapper.py


示例11: map_tanh

 def map_tanh(cls, node):
     return Node.create('Tanh')
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:2,代码来源:mapper.py


示例12: map_reshape

 def map_reshape(cls, node):
     kwargs = {'shape' : [dim for dim in node.output_shape]}
     cls._convert_output_shape(kwargs, node)
     return Node.create('Reshape', **kwargs)
开发者ID:Wang-Yujue,项目名称:MMdnn,代码行数:4,代码来源:mapper.py


示例13: map_abs_val

 def map_abs_val(cls, node):
     return Node.create('Abs')
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:2,代码来源:mapper.py


示例14: map_batch_norm

 def map_batch_norm(cls, node):
     kwargs = {'scale' : len(node.data) >= 3, 'bias' : len(node.data) == 4}
     epsilon = node.parameters.eps
     kwargs['epsilon'] = epsilon
     cls._convert_output_shape(kwargs, node)
     return Node.create('BatchNorm', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:6,代码来源:mapper.py


示例15: map_flatten

 def map_flatten(cls, node):
     return Node.create('Flatten')
开发者ID:Wang-Yujue,项目名称:MMdnn,代码行数:2,代码来源:mapper.py


示例16: map_dropout

 def map_dropout(cls, node):
     kwargs = {'keep_prob': node.parameters.dropout_ratio}
     cls._convert_output_shape(kwargs, node)
     return Node.create('Dropout', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:4,代码来源:mapper.py


示例17: map_concat

 def map_concat(cls, node):
     kwargs = {'axis': (2, 3, 1, 0)[node.parameters.axis]}
     cls._convert_output_shape(kwargs, node)
     return Node.create('Concat', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:4,代码来源:mapper.py


示例18: map_lrn

 def map_lrn(cls, node):
     params = node.parameters
     assert params.local_size % 2 == 1
     kwargs = {'size': int((params.local_size + 1) / 2), 'alpha': params.alpha, 'beta': params.beta, 'k' : params.k}
     cls._convert_output_shape(kwargs, node)
     return Node.create('LRN', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:6,代码来源:mapper.py


示例19: map_relu

 def map_relu(cls, node):
     kwargs = {}
     cls._convert_output_shape(kwargs, node)
     return Node.create('Relu', **kwargs)
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:4,代码来源:mapper.py


示例20: map_sigmoid

 def map_sigmoid(cls, node):
     return Node.create('Sigmoid')
开发者ID:skybigzhou,项目名称:MMdnn,代码行数:2,代码来源:mapper.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python bytereader.ByteReader类代码示例发布时间:2022-05-27
下一篇:
Python mmctools.SecurityContext类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap