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


Python layers.MaxPooling3D方法代码示例

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


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

示例1: down_stage

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def down_stage(inputs, filters, kernel_size=3,
               activation="relu", padding="SAME"):
    conv = Conv3D(filters, kernel_size,
                  activation=activation, padding=padding)(inputs)
    conv = GroupNormalization()(conv)
    conv = Conv3D(filters, kernel_size,
                  activation=activation, padding=padding)(conv)
    conv = GroupNormalization()(conv)
    pool = MaxPooling3D()(conv)
    return conv, pool 
开发者ID:sandialabs,项目名称:bcnn,代码行数:12,代码来源:dropout_vnet.py

示例2: down_stage

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def down_stage(inputs, filters, kernel_size=3,
             activation="relu", padding="SAME"):
    conv = Conv3D(filters, kernel_size,
                  activation=activation, padding=padding)(inputs)
    conv = GroupNormalization()(conv)
    conv = Conv3D(filters, kernel_size,
                  activation=activation, padding=padding)(conv)
    conv = GroupNormalization()(conv)
    pool = MaxPooling3D()(conv)
    return conv, pool 
开发者ID:sandialabs,项目名称:bcnn,代码行数:12,代码来源:bayesian_vnet.py

示例3: contracting_layer_3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def contracting_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
    conv1 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(input)
    if ba_norm : conv1 = BatchNormalization(momentum=ba_norm_momentum)(conv1)
    conc1 = concatenate([input, conv1], axis=-1)
    conv2 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(conc1)
    if ba_norm : conv2 = BatchNormalization(momentum=ba_norm_momentum)(conv2)
    conc2 = concatenate([input, conv2], axis=-1)
    pool = MaxPooling3D(pool_size=(2, 2, 2))(conc2)
    return pool, conc2

# Create the middle layer between the contracting and expanding layers 
开发者ID:frankkramer-lab,项目名称:MIScnn,代码行数:13,代码来源:dense.py

示例4: contracting_layer_3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def contracting_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
    conv1 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(input)
    if ba_norm : conv1 = BatchNormalization(momentum=ba_norm_momentum)(conv1)
    conv2 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(conv1)
    if ba_norm : conv2 = BatchNormalization(momentum=ba_norm_momentum)(conv2)
    conc = concatenate([input, conv2], axis=-1)
    pool = MaxPooling3D(pool_size=(2, 2, 2))(conc)
    return pool, conc

# Create the middle layer between the contracting and expanding layers 
开发者ID:frankkramer-lab,项目名称:MIScnn,代码行数:12,代码来源:compact.py

示例5: contracting_layer_3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def contracting_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
    conv1 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(input)
    if ba_norm : conv1 = BatchNormalization(momentum=ba_norm_momentum)(conv1)
    conv2 = Conv3D(neurons, (3,3,3), activation='relu', padding='same')(conv1)
    if ba_norm : conv2 = BatchNormalization(momentum=ba_norm_momentum)(conv2)
    shortcut = Conv3D(neurons, (1, 1, 1), activation='relu', padding="same")(input)
    add_layer = add([shortcut, conv2])
    pool = MaxPooling3D(pool_size=(2, 2, 2))(add_layer)
    return pool, add_layer

# Create the middle layer between the contracting and expanding layers 
开发者ID:frankkramer-lab,项目名称:MIScnn,代码行数:13,代码来源:residual.py

示例6: create_model_3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def create_model_3D(self, input_shape, n_labels=2):
        # Input layer
        inputs = Input(input_shape)

        # MultiResUNet 3D model code
        mresblock1 = MultiResBlock_3D(32, inputs)
        pool1 = MaxPooling3D(pool_size=(2, 2, 2))(mresblock1)
        mresblock1 = ResPath_3D(32, 4, mresblock1)

        mresblock2 = MultiResBlock_3D(32*2, pool1)
        pool2 = MaxPooling3D(pool_size=(2, 2, 2))(mresblock2)
        mresblock2 = ResPath_3D(32*2, 3,mresblock2)

        mresblock3 = MultiResBlock_3D(32*4, pool2)
        pool3 = MaxPooling3D(pool_size=(2, 2, 2))(mresblock3)
        mresblock3 = ResPath_3D(32*4, 2,mresblock3)

        mresblock4 = MultiResBlock_3D(32*8, pool3)
        pool4 = MaxPooling3D(pool_size=(2, 2, 2))(mresblock4)
        mresblock4 = ResPath_3D(32*8, 1,mresblock4)

        mresblock5 = MultiResBlock_3D(32*16, pool4)

        up6 = concatenate([Conv3DTranspose(32*8, (2, 2, 2), strides=(2, 2, 2), padding='same')(mresblock5), mresblock4], axis=4)
        mresblock6 = MultiResBlock_3D(32*8,up6)

        up7 = concatenate([Conv3DTranspose(32*4, (2, 2, 2), strides=(2, 2, 2), padding='same')(mresblock6), mresblock3], axis=4)
        mresblock7 = MultiResBlock_3D(32*4,up7)

        up8 = concatenate([Conv3DTranspose(32*2, (2, 2, 2), strides=(2, 2, 2), padding='same')(mresblock7), mresblock2], axis=4)
        mresblock8 = MultiResBlock_3D(32*2,up8)

        up9 = concatenate([Conv3DTranspose(32, (2, 2, 2), strides=(2, 2, 2), padding='same')(mresblock8), mresblock1], axis=4)
        mresblock9 = MultiResBlock_3D(32,up9)

        conv10 = conv3d_bn(mresblock9 , n_labels, 1, 1, 1, activation=self.activation)

        model = Model(inputs=[inputs], outputs=[conv10])
        return model

#-----------------------------------------------------#
#             Subroutines for 3D version              #
#-----------------------------------------------------# 
开发者ID:frankkramer-lab,项目名称:MIScnn,代码行数:45,代码来源:multiRes.py

示例7: create_model_3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def create_model_3D(self, input_shape, n_labels=2):
        # Input layer
        inputs = Input(input_shape)
        # Start the CNN Model chain with adding the inputs as first tensor
        cnn_chain = inputs
        # Cache contracting normalized conv layers
        # for later copy & concatenate links
        contracting_convs = []

        # First contracting layer
        neurons = self.feature_map[0]
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
        contracting_convs.append(cnn_chain)
        cnn_chain = MaxPooling3D(pool_size=(1, 2, 2))(cnn_chain)

        # Remaining contracting layers
        for i in range(1, len(self.feature_map)):
            neurons = self.feature_map[i]
            cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
            cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
            contracting_convs.append(cnn_chain)
            cnn_chain = MaxPooling3D(pool_size=(2, 2, 2))(cnn_chain)

        # Middle Layer
        neurons = self.feature_map[-1]
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)

        # Expanding Layers except last layer
        for i in reversed(range(1, len(self.feature_map))):
            neurons = self.feature_map[i]
            cnn_chain = Conv3DTranspose(neurons, (2, 2, 2), strides=(2, 2, 2),
                                        padding='same')(cnn_chain)
            cnn_chain = concatenate([cnn_chain, contracting_convs[i]], axis=-1)
            cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
            cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)

        # Last expanding layer
        neurons = self.feature_map[0]
        cnn_chain = Conv3DTranspose(neurons, (1, 2, 2), strides=(1, 2, 2),
                                    padding='same')(cnn_chain)
        cnn_chain = concatenate([cnn_chain, contracting_convs[0]], axis=-1)
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)
        cnn_chain = conv_layer_3D(cnn_chain, neurons, self.ba_norm, strides=1)

        # Output Layer
        conv_out = Conv3D(n_labels, (1, 1, 1), activation=self.activation)(cnn_chain)
        # Create Model with associated input and output layers
        model = Model(inputs=[inputs], outputs=[conv_out])
        # Return model
        return model

#-----------------------------------------------------#
#                   Subroutines 2D                    #
#-----------------------------------------------------#
# Convolution layer 
开发者ID:frankkramer-lab,项目名称:MIScnn,代码行数:59,代码来源:plain.py

示例8: unet3D

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def unet3D(x_in,
           img_shape, out_im_chans,
           nf_enc=[64, 64, 128, 128, 256, 256, 512],
           nf_dec=None,
           layer_prefix='unet',
           n_convs_per_stage=1,
        ):
    ks = 3
    x = x_in

    encodings = []
    encoding_vol_sizes = []
    for i in range(len(nf_enc)):
        for j in range(n_convs_per_stage):
            x = Conv3D(
                nf_enc[i],
                kernel_size=ks,
                strides=(1, 1, 1), padding='same',
                name='{}_enc_conv3D_{}_{}'.format(layer_prefix, i, j + 1))(x)
            x = LeakyReLU(0.2)(x)

        encodings.append(x)
        encoding_vol_sizes.append(np.asarray(x.get_shape().as_list()[1:-1]))

        if i < len(nf_enc) - 1:
            x = MaxPooling3D(pool_size=(2, 2, 2), padding='same', name='{}_enc_maxpool_{}'.format(layer_prefix, i))(x)

    if nf_dec is None:
        nf_dec = list(reversed(nf_enc[1:]))

    for i in range(len(nf_dec)):
        curr_shape = x.get_shape().as_list()[1:-1]

        # only do upsample if we are not yet at max resolution
        if np.any(curr_shape < list(img_shape[:len(curr_shape)])):
            us = (2, 2, 2)
            x = UpSampling3D(size=us, name='{}_dec_upsamp_{}'.format(layer_prefix, i))(x)

        # just concatenate the final layer here
        if i <= len(encodings) - 2:
            x = _pad_or_crop_to_shape_3D(x, np.asarray(x.get_shape().as_list()[1:-1]), encoding_vol_sizes[-i-2])
            x = Concatenate(axis=-1)([x, encodings[-i-2]])

        for j in range(n_convs_per_stage):
            x = Conv3D(nf_dec[i],
                       kernel_size=ks, strides=(1, 1, 1), padding='same',
                       name='{}_dec_conv3D_{}_{}'.format(layer_prefix, i, j))(x)
            x = LeakyReLU(0.2)(x)


    y = Conv3D(out_im_chans, kernel_size=1, padding='same',
               name='{}_dec_conv3D_final'.format(layer_prefix))(x)  # add your own activation after this model

    # add your own activation after this model
    return y 
开发者ID:xamyzhao,项目名称:brainstorm,代码行数:57,代码来源:networks.py

示例9: randflow_model

# 需要导入模块: from tensorflow.keras import layers [as 别名]
# 或者: from tensorflow.keras.layers import MaxPooling3D [as 别名]
def randflow_model(img_shape,
                   model,
                   model_name='randflow_model',
                   flow_sigma=None,
                   flow_amp=None,
                   blur_sigma=5,
                   interp_mode='linear',
                    indexing='xy',
                   ):
    n_dims = len(img_shape) - 1

    x_in = Input(img_shape, name='img_input_randwarp')

    if n_dims == 3:
        flow = MaxPooling3D(2)(x_in)
        flow = MaxPooling3D(2)(flow)
        blur_sigma = int(np.ceil(blur_sigma / 4.))
        flow_shape = tuple([int(s/4) for s in img_shape[:-1]] + [n_dims])
    else:
        flow = x_in
        flow_shape = img_shape[:-1] + (n_dims,)

    # random flow field
    if flow_amp is None:
        flow = RandFlow(name='randflow', img_shape=flow_shape, blur_sigma=blur_sigma, flow_sigma=flow_sigma)(flow)
    elif flow_sigma is None:
        flow = RandFlow_Uniform(name='randflow', img_shape=flow_shape, blur_sigma=blur_sigma, flow_amp=flow_amp)(flow)

    if n_dims == 3:
        flow = Reshape(flow_shape)(flow)
        # upsample with linear interpolation
        flow = Lambda(interp_upsampling)(flow)
        flow = Lambda(interp_upsampling, output_shape=img_shape[:-1] + (n_dims,))(flow)
        flow = Reshape(img_shape[:-1] + (n_dims,), name='randflow_out')(flow)
    else:
        flow = Reshape(img_shape[:-1] + (n_dims,), name='randflow_out')(flow)

    x_warped = SpatialTransformer(interp_method=interp_mode, name='densespatialtransformer_img', indexing=indexing)(
        [x_in, flow])


    if model is not None:
        model_outputs = model(x_warped)
        if not isinstance(model_outputs, list):
            model_outputs = [model_outputs]
    else:
        model_outputs = [x_warped, flow]
    return Model(inputs=[x_in], outputs=model_outputs, name=model_name) 
开发者ID:xamyzhao,项目名称:brainstorm,代码行数:50,代码来源:networks.py


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