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


Python common_graph.Node類代碼示例

本文整理匯總了Python中mmdnn.conversion.caffe.common_graph.Node的典型用法代碼示例。如果您正苦於以下問題:Python Node類的具體用法?Python Node怎麽用?Python Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Node類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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