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


Python convolutional.Conv3D方法代码示例

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


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

示例1: model

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def model(self):
        input_layer = Input(shape=self.INPUT_SHAPE)
        x = self.block(input_layer,filter_size=8)
        x = self.block(x,filter_size=16,)
        x = self.block(x,filter_size=32)
        x = self.block(x,filter_size=64)


        x = Conv3D(filters=1, kernel_size=(3,3,3),
                    strides=(1,1,1), kernel_initializer='glorot_normal',
                    bias_initializer='zeros', padding='valid')(x)
        x = BatchNormalization()(x)
        x = Flatten()(x)
        output_layer = Dense(1, activation='sigmoid')(x)

        model = Model(inputs=input_layer, outputs=output_layer)

        return model 
开发者ID:PacktPublishing,项目名称:Generative-Adversarial-Networks-Cookbook,代码行数:20,代码来源:discriminator.py

示例2: build_discriminator

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def build_discriminator(self):

        def d_layer(layer_input, filters, f_size=4, bn=True):
            """Discriminator layer"""
            d = Conv3D(filters, kernel_size=f_size, strides=2, padding='same')(layer_input)
            d = LeakyReLU(alpha=0.2)(d)
            if bn:
                d = BatchNormalization(momentum=0.8)(d)
            return d

        img_A = Input(shape=self.img_shape)
        img_B = Input(shape=self.img_shape)

        # Concatenate image and conditioning image by channels to produce input
        model_input = Concatenate(axis=-1)([img_A, img_B])

        d1 = d_layer(model_input, self.df, bn=False)
        d2 = d_layer(d1, self.df * 2)
        d3 = d_layer(d2, self.df * 4)
        d4 = d_layer(d3, self.df * 8)

        validity = Conv3D(1, kernel_size=4, strides=1, padding='same')(d4)

        return Model([img_A, img_B], validity) 
开发者ID:ymirsky,项目名称:CT-GAN,代码行数:26,代码来源:trainer.py

示例3: fCreateVNet_Block

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def fCreateVNet_Block(input_t, channels, type=1, kernel_size=(3, 3, 3), l1_reg=0.0, l2_reg=1e-6, iPReLU=0, dr_rate=0):
    tower_t = Dropout(dr_rate)(input_t)
    tower_t = Conv3D(channels,
                     kernel_size=kernel_size,
                     kernel_initializer='he_normal',
                     weights=None,
                     padding='same',
                     strides=(1, 1, 1),
                     kernel_regularizer=l1_l2(l1_reg, l2_reg),
                     )(tower_t)

    tower_t = fGetActivation(tower_t, iPReLU=iPReLU)
    for counter in range(1, type):
        tower_t = Dropout(dr_rate)(tower_t)
        tower_t = Conv3D(channels,
                         kernel_size=kernel_size,
                         kernel_initializer='he_normal',
                         weights=None,
                         padding='same',
                         strides=(1, 1, 1),
                         kernel_regularizer=l1_l2(l1_reg, l2_reg),
                         )(tower_t)
        tower_t = fGetActivation(tower_t, iPReLU=iPReLU)
    tower_t = concatenate([tower_t, input_t], axis=1)
    return tower_t 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:27,代码来源:VNetArt.py

示例4: fCreateVNet_Block

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def fCreateVNet_Block( input_t, channels, type=1, kernel_size=(3,3,3),l1_reg=0.0, l2_reg=1e-6, iPReLU=0, dr_rate=0):
    tower_t= Dropout(dr_rate)(input_t)
    tower_t = Conv3D(channels,
                           kernel_size=kernel_size,
                           kernel_initializer='he_normal',
                           weights=None,
                           padding='same',
                           strides=(1, 1, 1),
                           kernel_regularizer=l1_l2(l1_reg, l2_reg),
                           )(tower_t)

    tower_t = fGetActivation(tower_t, iPReLU=iPReLU)
    for counter in range(1, type):
        tower_t = Dropout(dr_rate)(tower_t)
        tower_t = Conv3D(channels,
                           kernel_size=kernel_size,
                           kernel_initializer='he_normal',
                           weights=None,
                           padding='same',
                           strides=(1, 1, 1),
                           kernel_regularizer=l1_l2(l1_reg, l2_reg),
                           )(tower_t)
        tower_t = fGetActivation(tower_t, iPReLU=iPReLU)
    tower_t = concatenate([tower_t, input_t], axis=1)
    return tower_t 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:27,代码来源:motion_VNetArt.py

示例5: InceptionBlock

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def InceptionBlock(inp, l1_reg=0.0, l2_reg=1e-6):
    KN = fgetKernelNumber()
    branch1 = Conv3D(filters=KN[0], kernel_size=(1,1,1), kernel_initializer='he_normal', weights=None,padding='same',
                     strides=(1,1,1),kernel_regularizer=l1_l2(l1_reg, l2_reg),activation='relu')(inp)

    branch3 = Conv3D(filters=KN[0], kernel_size=(1, 1, 1), kernel_initializer='he_normal', weights=None, padding='same',
                     strides=(1, 1, 1), kernel_regularizer=l1_l2(l1_reg, l2_reg), activation='relu')(inp)
    branch3 = Conv3D(filters=KN[2], kernel_size=(3, 3, 3), kernel_initializer='he_normal', weights=None, padding='same',
                     strides=(1, 1, 1), kernel_regularizer=l1_l2(l1_reg, l2_reg), activation='relu')(branch3)

    branch5 = Conv3D(filters=KN[0], kernel_size=(1, 1, 1), kernel_initializer='he_normal', weights=None, padding='same',
                     strides=(1, 1, 1), kernel_regularizer=l1_l2(l1_reg, l2_reg), activation='relu')(inp)
    branch5 = Conv3D(filters=KN[1], kernel_size=(5, 5, 5), kernel_initializer='he_normal', weights=None, padding='same',
                     strides=(1, 1, 1), kernel_regularizer=l1_l2(l1_reg, l2_reg), activation='relu')(branch5)

    branchpool = MaxPooling3D(pool_size=(3,3,3),strides=(1,1,1),padding='same',data_format='channels_first')(inp)
    branchpool = Conv3D(filters=KN[0], kernel_size=(1, 1, 1), kernel_initializer='he_normal', weights=None, padding='same',
                     strides=(1, 1, 1), kernel_regularizer=l1_l2(l1_reg, l2_reg), activation='relu')(branchpool)
    out = concatenate([branch1, branch3, branch5, branchpool], axis=1)
    return out 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:22,代码来源:MSnetworks.py

示例6: block

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def block(self,first_layer,filter_size=512,kernel_size=(3,3,3)):

        x = Conv3D(filters=filter_size, kernel_size=kernel_size, kernel_initializer='glorot_normal',
                    bias_initializer='zeros', padding='same')(first_layer)
        x = BatchNormalization()(x)
        x = LeakyReLU(0.2)(x)

        return x 
开发者ID:PacktPublishing,项目名称:Generative-Adversarial-Networks-Cookbook,代码行数:10,代码来源:discriminator.py

示例7: DenseNetUnit3D

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def DenseNetUnit3D(x, growth_rate, ksize, n, bn_decay=0.99):
    for i in range(n):
        concat = x
        x = BatchNormalization(center=True, scale=True, momentum=bn_decay)(x)
        x = Activation('relu')(x)
        x = Conv3D(filters=growth_rate, kernel_size=ksize, padding='same', kernel_initializer='he_uniform',
                   use_bias=False)(x)
        x = concatenate([concat, x])
    return x 
开发者ID:lelechen63,项目名称:MRI-tumor-segmentation-Brats,代码行数:11,代码来源:test.py

示例8: DenseNetTransit

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def DenseNetTransit(x, rate=1, name=None):
    if rate != 1:
        out_features = x.get_shape().as_list()[-1] * rate
        x = BatchNormalization(center=True, scale=True, name=name + '_bn')(x)
        x = Activation('relu', name=name + '_relu')(x)
        x = Conv3D(filters=out_features, kernel_size=1, strides=1, padding='same', kernel_initializer='he_normal',
                   use_bias=False, name=name + '_conv')(x)
    x = AveragePooling3D(pool_size=2, strides=2, padding='same')(x)
    return x 
开发者ID:lelechen63,项目名称:MRI-tumor-segmentation-Brats,代码行数:11,代码来源:test.py

示例9: dense_net

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def dense_net(input):
    x = Conv3D(filters=24, kernel_size=3, strides=1, kernel_initializer='he_uniform', padding='same', use_bias=False)(
        input)
    x = DenseNetUnit3D(x, growth_rate=12, ksize=3, n=4)
    x = DenseNetTransit(x)
    x = DenseNetUnit3D(x, growth_rate=12, ksize=3, n=4)
    x = DenseNetTransit(x)
    x = DenseNetUnit3D(x, growth_rate=12, ksize=3, n=4)
    x = BatchNormalization()(x)
    x = Activation('relu')(x)
    return x 
开发者ID:lelechen63,项目名称:MRI-tumor-segmentation-Brats,代码行数:13,代码来源:test.py

示例10: dense_model

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def dense_model(patch_size, num_classes):
    merged_inputs = Input(shape=patch_size + (4,), name='merged_inputs')
    flair = Reshape(patch_size + (1,))(
        Lambda(
            lambda l: l[:, :, :, :, 0],
            output_shape=patch_size + (1,))(merged_inputs),
    )
    t2 = Reshape(patch_size + (1,))(
        Lambda(lambda l: l[:, :, :, :, 1], output_shape=patch_size + (1,))(merged_inputs)
    )
    t1 = Lambda(lambda l: l[:, :, :, :, 2:], output_shape=patch_size + (2,))(merged_inputs)

    flair = dense_net(flair)
    t2 = dense_net(t2)
    t1 = dense_net(t1)

    t2 = concatenate([flair, t2])

    t1 = concatenate([t2, t1])

    tumor = Conv3D(2, kernel_size=1, strides=1, name='tumor')(flair)
    core = Conv3D(3, kernel_size=1, strides=1, name='core')(t2)
    enhancing = Conv3D(num_classes, kernel_size=1, strides=1, name='enhancing')(t1)
    net = Model(inputs=merged_inputs, outputs=[tumor, core, enhancing])

    return net 
开发者ID:lelechen63,项目名称:MRI-tumor-segmentation-Brats,代码行数:28,代码来源:test.py

示例11: fCreateVNet_DownConv_Block

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def fCreateVNet_DownConv_Block(input_t, channels, stride, l1_reg=0.0, l2_reg=1e-6, iPReLU=0, dr_rate=0):
    output_t = Dropout(dr_rate)(input_t)
    output_t = Conv3D(channels,
                      kernel_size=stride,
                      strides=stride,
                      weights=None,
                      padding='valid',
                      kernel_regularizer=l1_l2(l1_reg, l2_reg),
                      kernel_initializer='he_normal'
                      )(output_t)
    output_t = fGetActivation(output_t, iPReLU=iPReLU)
    return output_t 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:14,代码来源:VNetArt.py

示例12: fCreateVNet_DownConv_Block

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def fCreateVNet_DownConv_Block(input_t,channels, stride, l1_reg=0.0, l2_reg=1e-6, iPReLU=0, dr_rate=0):
    output_t=Dropout(dr_rate)(input_t)
    output_t=Conv3D(channels,
                    kernel_size=stride,
                    strides=stride,
                    weights=None,
                    padding='valid',
                    kernel_regularizer=l1_l2(l1_reg, l2_reg),
                    kernel_initializer='he_normal'
                    )(output_t)
    output_t=fGetActivation(output_t,iPReLU=iPReLU)
    return output_t 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:14,代码来源:motion_VNetArt.py

示例13: fCreateModel_FCN_simple

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def fCreateModel_FCN_simple(patchSize,dr_rate=0.0, iPReLU=0, l1_reg=0.0, l2_reg=1e-6):
    # Total params: 1,223,831
    # Replace the dense layer with a convolutional layer with filters=2 for the two classes
    Strides = fgetStrides()
    kernelnumber = fgetKernelNumber()
    inp = Input(shape=(1, int(patchSize[0]), int(patchSize[1]), int(patchSize[2])))

    after_Conv_1 = fCreateVNet_Block(inp, kernelnumber[0], type=fgetLayerNumConv(), l2_reg=l2_reg)
    after_DownConv_1 = fCreateVNet_DownConv_Block(after_Conv_1, after_Conv_1._keras_shape[1], Strides[0],
                                                     iPReLU=iPReLU, dr_rate=dr_rate, l2_reg=l2_reg)

    after_Conv_2 = fCreateVNet_Block(after_DownConv_1, kernelnumber[1], type=fgetLayerNumConv(), l2_reg=l2_reg)
    after_DownConv_2 = fCreateVNet_DownConv_Block(after_Conv_2, after_Conv_2._keras_shape[1], Strides[1],
                                                   iPReLU=iPReLU, dr_rate=dr_rate, l2_reg=l2_reg)

    after_Conv_3 = fCreateVNet_Block(after_DownConv_2, kernelnumber[2], type=fgetLayerNumConv(), l2_reg=l2_reg)
    after_DownConv_3 = fCreateVNet_DownConv_Block(after_Conv_3, after_Conv_3._keras_shape[1], Strides[2],
                                                   iPReLU=iPReLU, dr_rate=dr_rate, l2_reg=l2_reg)

    dropout_out = Dropout(dr_rate)(after_DownConv_3)
    fclayer = Conv3D(2,
                       kernel_size=(1,1,1),
                       kernel_initializer='he_normal',
                       weights=None,
                       padding='valid',
                       strides=(1, 1, 1),
                       kernel_regularizer=l1_l2(l1_reg, l2_reg),
                       )(dropout_out)
    fclayer = GlobalAveragePooling3D()(fclayer)
    outp = Activation('softmax')(fclayer)
    cnn_spp = Model(inputs=inp, outputs=outp)
    return cnn_spp 
开发者ID:thomaskuestner,项目名称:CNNArt,代码行数:34,代码来源:MSnetworks.py

示例14: build

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def build(self):
        if K.image_data_format() == 'channels_first':
            input_shape = (self.img_c, self.frames_n, self.img_w, self.img_h)
        else:
            input_shape = (self.frames_n, self.img_w, self.img_h, self.img_c)

        self.input_data = Input(name='the_input', shape=input_shape, dtype='float32')

        self.zero1 = ZeroPadding3D(padding=(1, 2, 2), name='zero1')(self.input_data)
        self.conv1 = Conv3D(32, (3, 5, 5), strides=(1, 2, 2), activation='relu', kernel_initializer='he_normal', name='conv1')(self.zero1)
        self.maxp1 = MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2), name='max1')(self.conv1)
        self.drop1 = Dropout(0.5)(self.maxp1)

        self.zero2 = ZeroPadding3D(padding=(1, 2, 2), name='zero2')(self.drop1)
        self.conv2 = Conv3D(64, (3, 5, 5), strides=(1, 1, 1), activation='relu', kernel_initializer='he_normal', name='conv2')(self.zero2)
        self.maxp2 = MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2), name='max2')(self.conv2)
        self.drop2 = Dropout(0.5)(self.maxp2)

        self.zero3 = ZeroPadding3D(padding=(1, 1, 1), name='zero3')(self.drop2)
        self.conv3 = Conv3D(96, (3, 3, 3), strides=(1, 1, 1), activation='relu', kernel_initializer='he_normal', name='conv3')(self.zero3)
        self.maxp3 = MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2), name='max3')(self.conv3)
        self.drop3 = Dropout(0.5)(self.maxp3)

        self.resh1 = TimeDistributed(Flatten())(self.drop3)

        self.gru_1 = Bidirectional(GRU(256, return_sequences=True, kernel_initializer='Orthogonal', name='gru1'), merge_mode='concat')(self.resh1)
        self.gru_2 = Bidirectional(GRU(256, return_sequences=True, kernel_initializer='Orthogonal', name='gru2'), merge_mode='concat')(self.gru_1)

        # transforms RNN output to character activations:
        self.dense1 = Dense(self.output_size, kernel_initializer='he_normal', name='dense1')(self.gru_2)

        self.y_pred = Activation('softmax', name='softmax')(self.dense1)

        self.labels = Input(name='the_labels', shape=[self.absolute_max_string_len], dtype='float32')
        self.input_length = Input(name='input_length', shape=[1], dtype='int64')
        self.label_length = Input(name='label_length', shape=[1], dtype='int64')

        self.loss_out = CTC('ctc', [self.y_pred, self.labels, self.input_length, self.label_length])

        self.model = Model(inputs=[self.input_data, self.labels, self.input_length, self.label_length], outputs=self.loss_out) 
开发者ID:rizkiarm,项目名称:LipNet,代码行数:42,代码来源:model.py

示例15: build_discriminator

# 需要导入模块: from keras.layers import convolutional [as 别名]
# 或者: from keras.layers.convolutional import Conv3D [as 别名]
def build_discriminator():
    """
    Create a Discriminator Model using hyperparameters values defined as follows
    """

    dis_input_shape = (64, 64, 64, 1)
    dis_filters = [64, 128, 256, 512, 1]
    dis_kernel_sizes = [4, 4, 4, 4, 4]
    dis_strides = [2, 2, 2, 2, 1]
    dis_paddings = ['same', 'same', 'same', 'same', 'valid']
    dis_alphas = [0.2, 0.2, 0.2, 0.2, 0.2]
    dis_activations = ['leaky_relu', 'leaky_relu', 'leaky_relu',
                       'leaky_relu', 'sigmoid']
    dis_convolutional_blocks = 5

    dis_input_layer = Input(shape=dis_input_shape)

    # The first 3D Convolutional block
    a = Conv3D(filters=dis_filters[0],
               kernel_size=dis_kernel_sizes[0],
               strides=dis_strides[0],
               padding=dis_paddings[0])(dis_input_layer)
    # a = BatchNormalization()(a, training=True)
    a = LeakyReLU(dis_alphas[0])(a)

    # Next 4 3D Convolutional Blocks
    for i in range(dis_convolutional_blocks - 1):
        a = Conv3D(filters=dis_filters[i + 1],
                   kernel_size=dis_kernel_sizes[i + 1],
                   strides=dis_strides[i + 1],
                   padding=dis_paddings[i + 1])(a)
        a = BatchNormalization()(a, training=True)
        if dis_activations[i + 1] == 'leaky_relu':
            a = LeakyReLU(dis_alphas[i + 1])(a)
        elif dis_activations[i + 1] == 'sigmoid':
            a = Activation(activation='sigmoid')(a)

    dis_model = Model(inputs=[dis_input_layer], outputs=[a])
    return dis_model 
开发者ID:PacktPublishing,项目名称:Generative-Adversarial-Networks-Projects,代码行数:41,代码来源:run.py


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