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


Python cntk.FreeDimension方法代码示例

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


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

示例1: infer_outputs

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def infer_outputs(self):
        # sampled rois (0, x1, y1, x2, y2)
        # for CNTK the proposal shape is [4 x roisPerImage], and mirrored in Python
        rois_shape = (FreeDimension, 4)
        labels_shape = (FreeDimension, self._num_classes)
        bbox_targets_shape = (FreeDimension, self._num_classes * 4)
        bbox_inside_weights_shape = (FreeDimension, self._num_classes * 4)

        return [output_variable(rois_shape, self.inputs[0].dtype, self.inputs[0].dynamic_axes,
                                name="rpn_target_rois_raw", needs_gradient=False),
                output_variable(labels_shape, self.inputs[0].dtype, self.inputs[0].dynamic_axes,
                                name="label_targets_raw", needs_gradient=False),
                output_variable(bbox_targets_shape, self.inputs[0].dtype, self.inputs[0].dynamic_axes,
                                name="bbox_targets_raw", needs_gradient=False),
                output_variable(bbox_inside_weights_shape, self.inputs[0].dtype, self.inputs[0].dynamic_axes,
                                name="bbox_inside_w_raw", needs_gradient=False)] 
开发者ID:karolzak,项目名称:cntk-python-web-service-on-azure,代码行数:18,代码来源:proposal_target_layer.py

示例2: squeeze

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def squeeze(x, axis):
    if isinstance(axis, tuple):
        axis = list(axis)
    if not isinstance(axis, list):
        axis = [axis]

    shape = list(int_shape(x))

    _axis = []
    for _ in axis:
        if isinstance(_, int):
            _axis.append(_ if _ >= 0 else _ + len(shape))

    if len(_axis) == 0:
        return x

    nones = _get_dynamic_axis_num(x)
    for _ in sorted(_axis, reverse=True):
        del shape[_]

    new_shape = shape[nones:]
    new_shape = tuple([C.InferredDimension if _ == C.FreeDimension else _ for _ in new_shape])
    return C.reshape(x, new_shape) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:25,代码来源:cntk_backend.py

示例3: _reshape_dummy_dim

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def _reshape_dummy_dim(x, axis):
    shape = list(x.shape)

    _axis = [_ + len(shape) if _ < 0 else _ for _ in axis]

    if shape.count(C.InferredDimension) > 1 or shape.count(C.FreeDimension) > 1:
        result = x
        for index in sorted(_axis, reverse=True):
            result = C.reshape(result,
                               shape=(),
                               begin_axis=index,
                               end_axis=index + 1)
        return result
    else:
        for index in sorted(_axis, reverse=True):
            del shape[index]

        shape = [C.InferredDimension if _ == C.FreeDimension else _ for _ in shape]
        return C.reshape(x, shape) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:21,代码来源:cntk_backend.py

示例4: repeat

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def repeat(x, n):
    # this is a workaround for recurrent layer
    # if n is inferred dimension,
    # we can't figure out how to repeat it in cntk now
    # return the same x to take cntk broadcast feature
    # to make the recurrent layer work.
    # need to be fixed in GA.
    if n is C.InferredDimension or n is C.FreeDimension:
        return x
    index = 1 - _get_dynamic_axis_num(x)
    if index < 0 or index > 1:
        raise NotImplementedError

    new_shape = list(x.shape)
    new_shape.insert(index, 1)
    new_shape = tuple(new_shape)
    x = C.reshape(x, new_shape)
    temp = [x] * n
    return C.splice(*temp, axis=index) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:21,代码来源:cntk_backend.py

示例5: infer_outputs

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def infer_outputs(self):
        # rois blob: holds R regions of interest, each is a 5-tuple
        # (n, x1, y1, x2, y2) specifying an image batch index n and a
        # rectangle (x1, y1, x2, y2)
        # for CNTK the proposal shape is [4 x roisPerImage], and mirrored in Python
        proposalShape = (FreeDimension, 4)

        return [output_variable(proposalShape, self.inputs[0].dtype, self.inputs[0].dynamic_axes,
                            name="rpn_rois_raw", needs_gradient=False)] 
开发者ID:karolzak,项目名称:cntk-python-web-service-on-azure,代码行数:11,代码来源:proposal_layer.py

示例6: placeholder

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def placeholder(
        shape=None,
        ndim=None,
        dtype=None,
        sparse=False,
        name=None,
        dynamic_axis_num=1):
    if dtype is None:
        dtype = floatx()
    if not shape:
        if ndim:
            shape = tuple([None for _ in range(ndim)])

    dynamic_dimension = C.FreeDimension if _get_cntk_version() >= 2.2 else C.InferredDimension
    cntk_shape = [dynamic_dimension if s is None else s for s in shape]
    cntk_shape = tuple(cntk_shape)

    if dynamic_axis_num > len(cntk_shape):
        raise ValueError('CNTK backend: creating placeholder with '
                         '%d dimension is not supported, at least '
                         '%d dimensions are needed.'
                         % (len(cntk_shape), dynamic_axis_num))

    if name is None:
        name = ''

    cntk_shape = cntk_shape[dynamic_axis_num:]

    x = C.input(
        shape=cntk_shape,
        dtype=_convert_string_dtype(dtype),
        is_sparse=sparse,
        name=name)
    x._keras_shape = shape
    x._uses_learning_phase = False
    x._cntk_placeholder = True
    return x 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:39,代码来源:cntk_backend.py

示例7: count_params

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import FreeDimension [as 别名]
def count_params(x):
    for _ in x.shape:
        if _ == C.InferredDimension or _ == C.FreeDimension:
            raise ValueError('CNTK backend: `count_params` with dynamic '
                             'shape is not supported. Please provide '
                             'fixed dimension instead of `None`.')

    return np.prod(int_shape(x)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:cntk_backend.py


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