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


Python conv_utils.normalize_data_format方法代码示例

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


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

示例1: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, target_shape, offset=None, data_format=None,
                 **kwargs):
        """Crop to target.

        If only one `offset` is set, then all dimensions are offset by this amount.

        """
        super(CroppingLike2D, self).__init__(**kwargs)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.target_shape = target_shape
        if offset is None or offset == 'centered':
            self.offset = 'centered'
        elif isinstance(offset, int):
            self.offset = (offset, offset)
        elif hasattr(offset, '__len__'):
            if len(offset) != 2:
                raise ValueError('`offset` should have two elements. '
                                 'Found: ' + str(offset))
            self.offset = offset
        self.input_spec = InputSpec(ndim=4) 
开发者ID:JihongJu,项目名称:keras-fcn,代码行数:22,代码来源:layers.py

示例2: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, padding=(1, 1), data_format=None, **kwargs):
        super(ReflectionPadding2D, self).__init__(**kwargs)
        self.data_format = conv_utils.normalize_data_format(data_format)
        if isinstance(padding, int):
            self.padding = ((padding, padding), (padding, padding))
        elif hasattr(padding,"__len__"):
            if len(padding) != 2:
                 raise ValueError('`padding` should have two elements. '
                                  'Found: ' + str(padding))
            height_padding = conv_utils.normalize_tuple(padding[0], 2, "1st entry of padding")
            width_padding = conv_utils.normalize_tuple(padding[1], 2, "2nd entry of padding")
            self.padding = (height_padding, width_padding)
        else:
            raise ValueError('`padding` should be either an int, '
                             'a tuple of 2 ints '
                             '(symmetric_height_pad, symmetric_width_pad), '
                             'or a tuple of 2 tuples of 2 ints '
                             '((top_pad, bottom_pad), (left_pad, right_pad)). '
                             'Found: ' + str(padding))
            self.input_spec = InputSpec(ndim=4) 
开发者ID:jarvisqi,项目名称:deep_learning,代码行数:22,代码来源:layer_utils.py

示例3: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, target_layer, data_format=None, **kwargs):
        """
        :param target_layer: Tensor or variable. Resize the images to the same size as it is.
        :param data_format: A string,
            one of `channels_last` (default) or `channels_first`.
            The ordering of the dimensions in the inputs.
            `channels_last` corresponds to inputs with shape
            `(batch, height, width, channels)` while `channels_first`
            corresponds to inputs with shape
            `(batch, channels, height, width)`.
            It defaults to the `image_data_format` value found in your
            Keras config file at `~/.keras/keras.json`.
            If you never set it, then it will be "channels_last".
        :param kwargs:
        """
        super(Interpolate, self).__init__(**kwargs)
        self.target_layer = target_layer
        self.target_shape = _collect_input_shape(target_layer)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.input_spec = InputSpec(ndim=4) 
开发者ID:RubanSeven,项目名称:CRAFT_keras,代码行数:22,代码来源:interpolate.py

示例4: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, size=(2, 2), data_format=None, **kwargs):
        super(PixelShuffler, self).__init__(**kwargs)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.size = conv_utils.normalize_tuple(size, 2, 'size') 
开发者ID:dfaker,项目名称:df,代码行数:6,代码来源:pixel_shuffler.py

示例5: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, target_shape, offset=None, data_format=None, **kwargs):
        super(CroppingLike2D, self).__init__(**kwargs)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.target_shape = target_shape
        if offset is None or offset == 'centered':
            self.offset = 'centered'
        elif isinstance(offset, int):
            self.offset = (offset, offset)
        elif hasattr(offset, '__len__'):
            if len(offset) != 2:
                raise ValueError('`offset` should have two elements. '
                                 'Found: ' + str(offset))
            self.offset = offset
        self.input_spec = InputSpec(ndim=4) 
开发者ID:dhkim0225,项目名称:keras-image-segmentation,代码行数:16,代码来源:pspnet.py

示例6: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, rank,
                 filters,
                 kernel_size,
                 strides=1,
                 padding='valid',
                 data_format=None,
                 dilation_rate=1,
                 activation=None,
                 use_bias=True,
                 kernel_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 kernel_regularizer=None,
                 bias_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 bias_constraint=None,
                 spectral_normalization=True,
                 **kwargs):
        super(_ConvSN, self).__init__(**kwargs)
        self.rank = rank
        self.filters = filters
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, rank, 'kernel_size')
        self.strides = conv_utils.normalize_tuple(strides, rank, 'strides')
        self.padding = conv_utils.normalize_padding(padding)
        self.data_format = conv_utils.normalize_data_format(data_format)
        self.dilation_rate = conv_utils.normalize_tuple(dilation_rate, rank, 'dilation_rate')
        self.activation = activations.get(activation)
        self.use_bias = use_bias
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.input_spec = InputSpec(ndim=self.rank + 2)
        self.spectral_normalization = spectral_normalization
        self.u = None 
开发者ID:emilwallner,项目名称:Coloring-greyscale-images,代码行数:40,代码来源:sn.py

示例7: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, scale_factor=2, data_format=None, **kwargs):
        super(SubPixelUpscaling, self).__init__(**kwargs)

        self.scale_factor = scale_factor
        self.data_format = normalize_data_format(data_format) 
开发者ID:OlafenwaMoses,项目名称:Model-Playgrounds,代码行数:7,代码来源:subpixel.py

示例8: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, padding=1, data_format=None, **kwargs):
        super(ChannelPadding, self).__init__(**kwargs)
        self.padding = conv_utils.normalize_tuple(padding, 2, 'padding')
        self.data_format = normalize_data_format(data_format)
        self.input_spec = InputSpec(ndim=4) 
开发者ID:cvjena,项目名称:semantic-embeddings,代码行数:7,代码来源:cifar_resnet.py

示例9: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, upsampling=(2, 2), output_size=None, data_format=None, **kwargs):

        super(BilinearUpsampling, self).__init__(**kwargs)

        self.data_format = conv_utils.normalize_data_format(data_format)
        self.input_spec = InputSpec(ndim=4)
        if output_size:
            self.output_size = conv_utils.normalize_tuple(
                output_size, 2, 'output_size')
            self.upsampling = None
        else:
            self.output_size = None
            self.upsampling = conv_utils.normalize_tuple(
                upsampling, 2, 'upsampling') 
开发者ID:EmmaW8,项目名称:pOSAL,代码行数:16,代码来源:models.py

示例10: test_invalid_data_format

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def test_invalid_data_format():
    with pytest.raises(ValueError):
        conv_utils.normalize_data_format('channels_middle') 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:5,代码来源:conv_utils_test.py

示例11: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, 
                 ratio, 
                 data_format=None,
                 use_bias=True,
                 kernel_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 kernel_regularizer=None,
                 bias_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 bias_constraint=None,
                 **kwargs):
        super(SE, self).__init__(**kwargs)

        self.ratio = ratio
        self.data_format= conv_utils.normalize_data_format(data_format)

        self.use_bias = use_bias
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.supports_masking = True 
开发者ID:DingKe,项目名称:nn_playground,代码行数:28,代码来源:layers.py

示例12: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, ch_j, n_j,
                 kernel_size=(3, 3),
                 strides=(1, 1),
                 r_num=1,
                 b_alphas=[8, 8, 8],
                 padding='same',
                 data_format='channels_last',
                 dilation_rate=(1, 1),
                 kernel_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 kernel_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 **kwargs):
        super(Conv2DCaps, self).__init__(**kwargs)
        rank = 2
        self.ch_j = ch_j  # Number of capsules in layer J
        self.n_j = n_j  # Number of neurons in a capsule in J
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, rank, 'kernel_size')
        self.strides = conv_utils.normalize_tuple(strides, rank, 'strides')
        self.r_num = r_num
        self.b_alphas = b_alphas
        self.padding = conv_utils.normalize_padding(padding)
        #self.data_format = conv_utils.normalize_data_format(data_format)
        self.data_format = K.normalize_data_format(data_format)
        self.dilation_rate = (1, 1)
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.input_spec = InputSpec(ndim=rank + 3) 
开发者ID:brjathu,项目名称:deepcaps,代码行数:34,代码来源:capslayers.py

示例13: __init__

# 需要导入模块: from keras.utils import conv_utils [as 别名]
# 或者: from keras.utils.conv_utils import normalize_data_format [as 别名]
def __init__(self, rank,
                 filters,
                 kernel_size,
                 strides=1,
                 padding='valid',
                 data_format=None,
                 dilation_rate=1,
                 activation=None,
                 use_bias=True,
                 normalize_weight=False,
                 kernel_initializer='complex',
                 bias_initializer='zeros',
                 gamma_diag_initializer=sqrt_init,
                 gamma_off_initializer='zeros',
                 kernel_regularizer=None,
                 bias_regularizer=None,
                 gamma_diag_regularizer=None,
                 gamma_off_regularizer=None,
                 activity_regularizer=None,
                 kernel_constraint=None,
                 bias_constraint=None,
                 gamma_diag_constraint=None,
                 gamma_off_constraint=None,
                 init_criterion='he',
                 seed=None,
                 spectral_parametrization=False,
                 epsilon=1e-7,
                 **kwargs):
        super(ComplexConv, self).__init__(**kwargs)
        self.rank = rank
        self.filters = filters
        self.kernel_size = conv_utils.normalize_tuple(kernel_size, rank, 'kernel_size')
        self.strides = conv_utils.normalize_tuple(strides, rank, 'strides')
        self.padding = conv_utils.normalize_padding(padding)
        self.data_format = 'channels_last' if rank == 1 else conv_utils.normalize_data_format(data_format)
        self.dilation_rate = conv_utils.normalize_tuple(dilation_rate, rank, 'dilation_rate')
        self.activation = activations.get(activation)
        self.use_bias = use_bias
        self.normalize_weight = normalize_weight
        self.init_criterion = init_criterion
        self.spectral_parametrization = spectral_parametrization
        self.epsilon = epsilon
        self.kernel_initializer = sanitizedInitGet(kernel_initializer)
        self.bias_initializer = sanitizedInitGet(bias_initializer)
        self.gamma_diag_initializer = sanitizedInitGet(gamma_diag_initializer)
        self.gamma_off_initializer = sanitizedInitGet(gamma_off_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.bias_regularizer = regularizers.get(bias_regularizer)
        self.gamma_diag_regularizer = regularizers.get(gamma_diag_regularizer)
        self.gamma_off_regularizer = regularizers.get(gamma_off_regularizer)
        self.activity_regularizer = regularizers.get(activity_regularizer)
        self.kernel_constraint = constraints.get(kernel_constraint)
        self.bias_constraint = constraints.get(bias_constraint)
        self.gamma_diag_constraint = constraints.get(gamma_diag_constraint)
        self.gamma_off_constraint = constraints.get(gamma_off_constraint)
        if seed is None:
            self.seed = np.random.randint(1, 10e6)
        else:
            self.seed = seed
        self.input_spec = InputSpec(ndim=self.rank + 2) 
开发者ID:ChihebTrabelsi,项目名称:deep_complex_networks,代码行数:62,代码来源:conv.py


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