コード例 #1
0
ファイル: __init__.py プロジェクト: higucheese/ideep
def convolution2DParam(out_dims, dy, dx, sy, sx, ph, pw, pd, pr):
    cp = conv2DParam()
    cp.out_dims = intVector()
    for d in out_dims:
        cp.out_dims.push_back(d)
    cp.dilate_y, cp.dilate_x = (dy - 1), (dx - 1)
    cp.sy, cp.sx = sy, sx
    cp.pad_lh, cp.pad_lw = ph, pw
    cp.pad_rh, cp.pad_rw = pd, pr
    return cp
コード例 #2
0
ファイル: __init__.py プロジェクト: higucheese/ideep
def pooling2DParam(out_dims, kh, kw, sy, sx, ph, pw, pd, pr, algo):
    pp = pol2DParam()
    pp.out_dims = intVector()
    for d in out_dims:
        pp.out_dims.push_back(d)
    pp.kh, pp.kw = kh, kw
    pp.sy, pp.sx = sy, sx
    pp.pad_lh, pp.pad_lw = ph, pw
    pp.pad_rh, pp.pad_rw = pd, pr
    pp.algo_kind = algo
    return pp
コード例 #3
0
ファイル: __init__.py プロジェクト: higucheese/ideep
def split(x, indices_or_sections, axis=0):
    if all_ready((x, )):
        offsets = intVector()
        if numpy.isscalar(indices_or_sections):
            if indices_or_sections == 0:
                raise ValueError('integer division or modulo by zero')
            elif x.shape[axis] % indices_or_sections:
                raise ValueError(
                    'array split does not result in an equal division')
            for i in range(x.shape[axis] / indices_or_sections, x.shape[axis],
                           x.shape[axis] / indices_or_sections):
                offsets.push_back(int(i))
        else:
            # FIXME
            # bypass python3 issue
            for i in indices_or_sections:
                offsets.push_back(int(i))

        ys = concat.Backward(x, offsets, axis)

        if ys:
            # indices_or_sections = [0, ...]
            # axis = 0
            if not numpy.isscalar(indices_or_sections) and \
                    axis == 0 and indices_or_sections[0] == 0:
                shape = x.shape
                shape = (0, ) + shape[1:]
                y1 = numpy.ndarray(shape, dtype=x.dtype)
                ys = list((y1, ) + ys)
        else:
            # For performance improvement

            # indices_or_sections = 1
            if numpy.isscalar(indices_or_sections) and \
                    indices_or_sections == 1:
                ys = [x]
            # indices_or_sections = [0]
            # axis = 0
            elif axis == 0 and indices_or_sections[0] == 0 \
                    and len(indices_or_sections) == 1:
                shape = x.shape
                shape = (0, ) + shape[1:]
                y1 = numpy.ndarray(shape, dtype=x.dtype)
                ys = list((y1, ) + (x, ))
            # other not support scenarios
            else:
                ys = numpy.split(x, indices_or_sections, axis)
    else:
        ys = numpy.split(x, indices_or_sections, axis)

    return ys