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


Python conv3d2d.conv3d方法代码示例

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


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

示例1: set_output

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def set_output(self):
        padding = self._padding
        input_shape = self._input_shape
        if np.sum(self._padding) > 0:
            padded_input = tensor.alloc(0.0,  # Value to fill the tensor
                                        input_shape[0],
                                        input_shape[1] + 2 * padding[1],
                                        input_shape[2],
                                        input_shape[3] + 2 * padding[3],
                                        input_shape[4] + 2 * padding[4])

            padded_input = tensor.set_subtensor(
                padded_input[:, padding[1]:padding[1] + input_shape[1], :, padding[3]:padding[3] +
                             input_shape[3], padding[4]:padding[4] + input_shape[4]],
                self._prev_layer.output)
        else:
            padded_input = self._prev_layer.output

        self._output = conv3d2d.conv3d(padded_input, self.W.val) + \
            self.b.val.dimshuffle('x', 'x', 0, 'x', 'x') 
开发者ID:chrischoy,项目名称:3D-R2N2,代码行数:22,代码来源:layers.py

示例2: __init__

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def __init__(self, prev_layers, axis=1):
        """
        list of prev layers to concatenate
        axis to concatenate

        For tensor5, channel dimension is axis=2 (due to theano conv3d
        convention). For image, axis=1
        """
        assert (len(prev_layers) > 1)
        super().__init__(prev_layers[0])
        self._axis = axis
        self._prev_layers = prev_layers

        self._output_shape = self._input_shape.copy()
        for prev_layer in prev_layers[1:]:
            self._output_shape[axis] += prev_layer._output_shape[axis]
        print('Concat the prev layer to [%s]' % ','.join(str(x) for x in self._output_shape)) 
开发者ID:chrischoy,项目名称:3D-R2N2,代码行数:19,代码来源:layers.py

示例3: conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def conv3d(x, kernel, strides=(1, 1, 1),
           border_mode='valid', dim_ordering='default',
           volume_shape=None, filter_shape=None,
           filter_dilation=(1, 1, 1)):
    '''3D convolution.

    # Arguments
        kernel: kernel tensor.
        strides: strides tuple.
        border_mode: string, "same" or "valid".
        dim_ordering: "tf" or "th".
            Whether to use Theano or TensorFlow dimension ordering
        in inputs/kernels/ouputs.
    '''
    if dim_ordering == 'default':
        dim_ordering = image_dim_ordering()
    if dim_ordering not in {'th', 'tf'}:
        raise Exception('Unknown dim_ordering ' + str(dim_ordering))

    # TODO: remove this if statement when Theano without AbstractConv3d is deprecated
    if not hasattr(T.nnet, 'conv3d'):
        if filter_dilation != (1, 1, 1):
            raise Exception('conv3d with filter dilation requires Theano '
                            '0.9.0dev3 or newer.')

        return _old_theano_conv3d(x, kernel, strides, border_mode,
                                  dim_ordering, volume_shape, filter_shape)

    x = _preprocess_conv3d_input(x, dim_ordering)
    kernel = _preprocess_conv3d_kernel(kernel, dim_ordering)
    th_border_mode = _preprocess_border_mode(border_mode)
    np_kernel = kernel.eval()
    volume_shape = _preprocess_conv3d_volume_shape(dim_ordering, volume_shape)
    filter_shape = _preprocess_conv3d_filter_shape(dim_ordering, filter_shape)

    conv_out = T.nnet.conv3d(x, kernel,
                             border_mode=th_border_mode,
                             subsample=strides,
                             input_shape=volume_shape,
                             filter_shape=filter_shape,
                             filter_dilation=filter_dilation)

    conv_out = _postprocess_conv3d_output(conv_out, x, border_mode, np_kernel,
                                          strides, dim_ordering)
    return conv_out


# TODO: remove this function when theano without AbstractConv3d is deprecated 
开发者ID:GeekLiB,项目名称:keras,代码行数:50,代码来源:theano_backend.py

示例4: conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def conv3d(x, kernel, strides=(1, 1, 1),
           border_mode='valid', dim_ordering='default',
           volume_shape=None, filter_shape=None,
           filter_dilation=(1, 1, 1)):
    """3D convolution.

    # Arguments
        kernel: kernel tensor.
        strides: strides tuple.
        border_mode: string, "same" or "valid".
        dim_ordering: "tf" or "th".
            Whether to use Theano or TensorFlow dimension ordering
        in inputs/kernels/ouputs.
    """
    if dim_ordering == 'default':
        dim_ordering = image_dim_ordering()
    if dim_ordering not in {'th', 'tf'}:
        raise ValueError('Unknown dim_ordering:', dim_ordering)

    # TODO: remove this if statement when Theano without AbstractConv3d is deprecated
    if not hasattr(T.nnet, 'conv3d'):
        if filter_dilation != (1, 1, 1):
            raise ValueError('conv3d with filter dilation requires Theano '
                             '0.9.0dev3 or newer.')

        return _old_theano_conv3d(x, kernel, strides, border_mode,
                                  dim_ordering, volume_shape, filter_shape)

    x = _preprocess_conv3d_input(x, dim_ordering)
    kernel = _preprocess_conv3d_kernel(kernel, dim_ordering)
    th_border_mode = _preprocess_border_mode(border_mode)

    if hasattr(kernel, '_keras_shape'):
        kernel_shape = kernel._keras_shape
    else:
        # Will only work if `kernel` is a shared variable.
        kernel_shape = kernel.eval().shape

    volume_shape = _preprocess_conv3d_volume_shape(dim_ordering, volume_shape)
    filter_shape = _preprocess_conv3d_filter_shape(dim_ordering, filter_shape)

    conv_out = T.nnet.conv3d(x, kernel,
                             border_mode=th_border_mode,
                             subsample=strides,
                             input_shape=volume_shape,
                             filter_shape=filter_shape,
                             filter_dilation=filter_dilation)

    conv_out = _postprocess_conv3d_output(conv_out, x, border_mode,
                                          kernel_shape, strides, dim_ordering)
    return conv_out


# TODO: remove this function when theano without AbstractConv3d is deprecated 
开发者ID:jasmeetsb,项目名称:deep-learning-keras-projects,代码行数:56,代码来源:theano_backend.py

示例5: _old_theano_conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def _old_theano_conv3d(x, kernel, strides=(1, 1, 1),
                       border_mode='valid', dim_ordering='default',
                       volume_shape=None, filter_shape=None):
    """
    Run on cuDNN if available.
    border_mode: string, "same" or "valid".
    """
    if dim_ordering == 'default':
        dim_ordering = image_dim_ordering()
    if dim_ordering not in {'th', 'tf'}:
        raise ValueError('Unknown dim_ordering:', dim_ordering)
    if border_mode not in {'same', 'valid'}:
        raise ValueError('Invalid border mode:', border_mode)

    if dim_ordering == 'tf':
        # TF uses the last dimension as channel dimension,
        # instead of the 2nd one.
        # TH input shape: (samples, input_depth, conv_dim1, conv_dim2, conv_dim3)
        # TF input shape: (samples, conv_dim1, conv_dim2, conv_dim3, input_depth)
        # TH kernel shape: (out_depth, input_depth, kernel_dim1, kernel_dim2, kernel_dim3)
        # TF kernel shape: (kernel_dim1, kernel_dim2, kernel_dim3, input_depth, out_depth)
        x = x.dimshuffle((0, 4, 1, 2, 3))
        kernel = kernel.dimshuffle((4, 3, 0, 1, 2))
        if volume_shape:
            volume_shape = (volume_shape[0], volume_shape[4],
                            volume_shape[1], volume_shape[2], volume_shape[3])
        if filter_shape:
            filter_shape = (filter_shape[4], filter_shape[3],
                            filter_shape[0], filter_shape[1], filter_shape[2])

    if border_mode == 'same':
        assert(strides == (1, 1, 1))
        pad_dim1 = (kernel.shape[2] - 1)
        pad_dim2 = (kernel.shape[3] - 1)
        pad_dim3 = (kernel.shape[4] - 1)
        output_shape = (x.shape[0], x.shape[1],
                        x.shape[2] + pad_dim1,
                        x.shape[3] + pad_dim2,
                        x.shape[4] + pad_dim3)
        output = T.zeros(output_shape)
        indices = (slice(None), slice(None),
                   slice(pad_dim1 // 2, x.shape[2] + pad_dim1 // 2),
                   slice(pad_dim2 // 2, x.shape[3] + pad_dim2 // 2),
                   slice(pad_dim3 // 2, x.shape[4] + pad_dim3 // 2))
        x = T.set_subtensor(output[indices], x)
        border_mode = 'valid'

    border_mode_3d = (border_mode, border_mode, border_mode)
    conv_out = conv3d2d.conv3d(signals=x.dimshuffle(0, 2, 1, 3, 4),
                               filters=kernel.dimshuffle(0, 2, 1, 3, 4),
                               border_mode=border_mode_3d)
    conv_out = conv_out.dimshuffle(0, 2, 1, 3, 4)

    # support strides by manually slicing the output
    if strides != (1, 1, 1):
        conv_out = conv_out[:, :, ::strides[0], ::strides[1], ::strides[2]]

    if dim_ordering == 'tf':
        conv_out = conv_out.dimshuffle((0, 2, 3, 4, 1))

    return conv_out 
开发者ID:jasmeetsb,项目名称:deep-learning-keras-projects,代码行数:63,代码来源:theano_backend.py

示例6: conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def conv3d(x, kernel, strides=(1, 1, 1),
           border_mode='valid', dim_ordering='default',
           volume_shape=None, filter_shape=None,
           filter_dilation=(1, 1, 1)):
    '''3D convolution.

    # Arguments
        kernel: kernel tensor.
        strides: strides tuple.
        border_mode: string, "same" or "valid".
        dim_ordering: "tf" or "th".
            Whether to use Theano or TensorFlow dimension ordering
        in inputs/kernels/ouputs.
    '''
    if dim_ordering == 'default':
        dim_ordering = image_dim_ordering()
    if dim_ordering not in {'th', 'tf'}:
        raise ValueError('Unknown dim_ordering:', dim_ordering)

    # TODO: remove this if statement when Theano without AbstractConv3d is deprecated
    if not hasattr(T.nnet, 'conv3d'):
        if filter_dilation != (1, 1, 1):
            raise ValueError('conv3d with filter dilation requires Theano '
                             '0.9.0dev3 or newer.')

        return _old_theano_conv3d(x, kernel, strides, border_mode,
                                  dim_ordering, volume_shape, filter_shape)

    x = _preprocess_conv3d_input(x, dim_ordering)
    kernel = _preprocess_conv3d_kernel(kernel, dim_ordering)
    th_border_mode = _preprocess_border_mode(border_mode)
    np_kernel = kernel.eval()
    volume_shape = _preprocess_conv3d_volume_shape(dim_ordering, volume_shape)
    filter_shape = _preprocess_conv3d_filter_shape(dim_ordering, filter_shape)

    conv_out = T.nnet.conv3d(x, kernel,
                             border_mode=th_border_mode,
                             subsample=strides,
                             input_shape=volume_shape,
                             filter_shape=filter_shape,
                             filter_dilation=filter_dilation)

    conv_out = _postprocess_conv3d_output(conv_out, x, border_mode, np_kernel,
                                          strides, dim_ordering)
    return conv_out


# TODO: remove this function when theano without AbstractConv3d is deprecated 
开发者ID:ambrite,项目名称:keras-customized,代码行数:50,代码来源:theano_backend.py

示例7: _old_theano_conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def _old_theano_conv3d(x, kernel, strides=(1, 1, 1),
                       border_mode='valid', dim_ordering='default',
                       volume_shape=None, filter_shape=None):
    '''
    Run on cuDNN if available.
    border_mode: string, "same" or "valid".
    '''
    if dim_ordering == 'default':
        dim_ordering = image_dim_ordering()
    if dim_ordering not in {'th', 'tf'}:
        raise ValueError('Unknown dim_ordering:', dim_ordering)
    if border_mode not in {'same', 'valid'}:
        raise ValueError('Invalid border mode:', border_mode)

    if dim_ordering == 'tf':
        # TF uses the last dimension as channel dimension,
        # instead of the 2nd one.
        # TH input shape: (samples, input_depth, conv_dim1, conv_dim2, conv_dim3)
        # TF input shape: (samples, conv_dim1, conv_dim2, conv_dim3, input_depth)
        # TH kernel shape: (out_depth, input_depth, kernel_dim1, kernel_dim2, kernel_dim3)
        # TF kernel shape: (kernel_dim1, kernel_dim2, kernel_dim3, input_depth, out_depth)
        x = x.dimshuffle((0, 4, 1, 2, 3))
        kernel = kernel.dimshuffle((4, 3, 0, 1, 2))
        if volume_shape:
            volume_shape = (volume_shape[0], volume_shape[4],
                            volume_shape[1], volume_shape[2], volume_shape[3])
        if filter_shape:
            filter_shape = (filter_shape[4], filter_shape[3],
                            filter_shape[0], filter_shape[1], filter_shape[2])

    if border_mode == 'same':
        assert(strides == (1, 1, 1))
        pad_dim1 = (kernel.shape[2] - 1)
        pad_dim2 = (kernel.shape[3] - 1)
        pad_dim3 = (kernel.shape[4] - 1)
        output_shape = (x.shape[0], x.shape[1],
                        x.shape[2] + pad_dim1,
                        x.shape[3] + pad_dim2,
                        x.shape[4] + pad_dim3)
        output = T.zeros(output_shape)
        indices = (slice(None), slice(None),
                   slice(pad_dim1 // 2, x.shape[2] + pad_dim1 // 2),
                   slice(pad_dim2 // 2, x.shape[3] + pad_dim2 // 2),
                   slice(pad_dim3 // 2, x.shape[4] + pad_dim3 // 2))
        x = T.set_subtensor(output[indices], x)
        border_mode = 'valid'

    border_mode_3d = (border_mode, border_mode, border_mode)
    conv_out = conv3d2d.conv3d(signals=x.dimshuffle(0, 2, 1, 3, 4),
                               filters=kernel.dimshuffle(0, 2, 1, 3, 4),
                               border_mode=border_mode_3d)
    conv_out = conv_out.dimshuffle(0, 2, 1, 3, 4)

    # support strides by manually slicing the output
    if strides != (1, 1, 1):
        conv_out = conv_out[:, :, ::strides[0], ::strides[1], ::strides[2]]

    if dim_ordering == 'tf':
        conv_out = conv_out.dimshuffle((0, 2, 3, 4, 1))

    return conv_out 
开发者ID:ambrite,项目名称:keras-customized,代码行数:63,代码来源:theano_backend.py

示例8: conv3d

# 需要导入模块: from theano.tensor.nnet import conv3d2d [as 别名]
# 或者: from theano.tensor.nnet.conv3d2d import conv3d [as 别名]
def conv3d(x, kernel, strides=(1, 1, 1),
           border_mode='valid', dim_ordering='th',
           volume_shape=None, filter_shape=None):
    '''
    Run on cuDNN if available.
    border_mode: string, "same" or "valid".
    '''
    if dim_ordering not in {'th', 'tf'}:
        raise Exception('Unknown dim_ordering ' + str(dim_ordering))

    if border_mode not in {'same', 'valid'}:
        raise Exception('Invalid border mode: ' + str(border_mode))

    if dim_ordering == 'tf':
        # TF uses the last dimension as channel dimension,
        # instead of the 2nd one.
        # TH input shape: (samples, input_depth, conv_dim1, conv_dim2, conv_dim3)
        # TF input shape: (samples, conv_dim1, conv_dim2, conv_dim3, input_depth)
        # TH kernel shape: (out_depth, input_depth, kernel_dim1, kernel_dim2, kernel_dim3)
        # TF kernel shape: (kernel_dim1, kernel_dim2, kernel_dim3, input_depth, out_depth)
        x = x.dimshuffle((0, 4, 1, 2, 3))
        kernel = kernel.dimshuffle((4, 3, 0, 1, 2))
        if volume_shape:
            volume_shape = (volume_shape[0], volume_shape[4],
                            volume_shape[1], volume_shape[2], volume_shape[3])
        if filter_shape:
            filter_shape = (filter_shape[4], filter_shape[3],
                            filter_shape[0], filter_shape[1], filter_shape[2])

    if border_mode == 'same':
        assert(strides == (1, 1, 1))
        pad_dim1 = (kernel.shape[2] - 1)
        pad_dim2 = (kernel.shape[3] - 1)
        pad_dim3 = (kernel.shape[4] - 1)
        output_shape = (x.shape[0], x.shape[1],
                        x.shape[2] + pad_dim1,
                        x.shape[3] + pad_dim2,
                        x.shape[4] + pad_dim3)
        output = T.zeros(output_shape)
        indices = (slice(None), slice(None),
                   slice(pad_dim1 // 2, x.shape[2] + pad_dim1 // 2),
                   slice(pad_dim2 // 2, x.shape[3] + pad_dim2 // 2),
                   slice(pad_dim3 // 2, x.shape[4] + pad_dim3 // 2))
        x = T.set_subtensor(output[indices], x)
        border_mode = 'valid'

    border_mode_3d = (border_mode, border_mode, border_mode)
    conv_out = conv3d2d.conv3d(signals=x.dimshuffle(0, 2, 1, 3, 4),
                               filters=kernel.dimshuffle(0, 2, 1, 3, 4),
                               border_mode=border_mode_3d)
    conv_out = conv_out.dimshuffle(0, 2, 1, 3, 4)

    # support strides by manually slicing the output
    if strides != (1, 1, 1):
        conv_out = conv_out[:, :, ::strides[0], ::strides[1], ::strides[2]]

    if dim_ordering == 'tf':
        conv_out = conv_out.dimshuffle((0, 2, 3, 4, 1))

    return conv_out 
开发者ID:mathDR,项目名称:reading-text-in-the-wild,代码行数:62,代码来源:theano_backend.py


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