本文整理匯總了Python中tensorflow.keras.layers.Conv3D方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.Conv3D方法的具體用法?Python layers.Conv3D怎麽用?Python layers.Conv3D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.keras.layers
的用法示例。
在下文中一共展示了layers.Conv3D方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: up_stage
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def up_stage(inputs, skip, filters, kernel_size=3,
activation="relu", padding="SAME"):
up = UpSampling3D()(inputs)
up = Conv3D(filters, 2, activation=activation, padding=padding)(up)
up = GroupNormalization()(up)
merge = concatenate([skip, up])
merge = GroupNormalization()(merge)
conv = Conv3D(filters, kernel_size,
activation=activation, padding=padding)(merge)
conv = GroupNormalization()(conv)
conv = Conv3D(filters, kernel_size,
activation=activation, padding=padding)(conv)
conv = GroupNormalization()(conv)
conv = SpatialDropout3D(0.5)(conv, training=True)
return conv
示例2: down_stage
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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
示例3: end_stage
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def end_stage(inputs, kernel_size=3, activation="relu", padding="SAME"):
conv = Conv3D(1, kernel_size, activation=activation, padding="SAME")(inputs)
conv = Conv3D(1, 1, activation="sigmoid")(conv)
return conv
示例4: down_stage
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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
示例5: create_model_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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 = []
# Contracting Layers
for i in range(0, self.depth):
neurons = self.n_filters * 2**i
cnn_chain, last_conv = contracting_layer_3D(cnn_chain, neurons,
self.ba_norm,
self.ba_norm_momentum)
contracting_convs.append(last_conv)
# Middle Layer
neurons = self.n_filters * 2**self.depth
cnn_chain = middle_layer_3D(cnn_chain, neurons, self.ba_norm,
self.ba_norm_momentum)
# Expanding Layers
for i in reversed(range(0, self.depth)):
neurons = self.n_filters * 2**i
cnn_chain = expanding_layer_3D(cnn_chain, neurons,
contracting_convs[i], self.ba_norm,
self.ba_norm_momentum)
# 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 #
#-----------------------------------------------------#
# Create a contracting layer
示例6: contracting_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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
示例7: middle_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def middle_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
conv_m1 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(input)
if ba_norm : conv_m1 = BatchNormalization(momentum=ba_norm_momentum)(conv_m1)
conc1 = concatenate([input, conv_m1], axis=-1)
conv_m2 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(conc1)
if ba_norm : conv_m2 = BatchNormalization(momentum=ba_norm_momentum)(conv_m2)
conc2 = concatenate([input, conv_m2], axis=-1)
return conc2
# Create an expanding layer
示例8: expanding_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def expanding_layer_3D(input, neurons, concatenate_link, ba_norm,
ba_norm_momentum):
up = concatenate([Conv3DTranspose(neurons, (2, 2, 2), strides=(2, 2, 2),
padding='same')(input), concatenate_link], axis=4)
conv1 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(up)
if ba_norm : conv1 = BatchNormalization(momentum=ba_norm_momentum)(conv1)
conc1 = concatenate([up, 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([up, conv2], axis=-1)
return conc2
示例9: middle_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def middle_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
conv_m1 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(input)
if ba_norm : conv_m1 = BatchNormalization(momentum=ba_norm_momentum)(conv_m1)
conv_m2 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(conv_m1)
if ba_norm : conv_m2 = BatchNormalization(momentum=ba_norm_momentum)(conv_m2)
conc = concatenate([input, conv_m2], axis=-1)
return conc
# Create an expanding layer
示例10: expanding_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def expanding_layer_3D(input, neurons, concatenate_link, ba_norm,
ba_norm_momentum):
up = concatenate([Conv3DTranspose(neurons, (2, 2, 2), strides=(2, 2, 2),
padding='same')(input), concatenate_link], axis=4)
conv1 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(up)
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([up, conv2], axis=-1)
return conc
示例11: contracting_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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
示例12: middle_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def middle_layer_3D(input, neurons, ba_norm, ba_norm_momentum):
conv_m1 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(input)
if ba_norm : conv_m1 = BatchNormalization(momentum=ba_norm_momentum)(conv_m1)
conv_m2 = Conv3D(neurons, (3, 3, 3), activation='relu', padding='same')(conv_m1)
if ba_norm : conv_m2 = BatchNormalization(momentum=ba_norm_momentum)(conv_m2)
shortcut = Conv3D(neurons, (1, 1, 1), activation='relu', padding="same")(input)
add_layer = add([shortcut, conv_m2])
return add_layer
# Create an expanding layer
示例13: conv3d_bn
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def conv3d_bn(x, filters, num_row, num_col, num_z, padding='same', strides=(1, 1, 1), activation='relu', name=None):
'''
3D Convolutional layers
Arguments:
x {keras layer} -- input layer
filters {int} -- number of filters
num_row {int} -- number of rows in filters
num_col {int} -- number of columns in filters
num_z {int} -- length along z axis in filters
Keyword Arguments:
padding {str} -- mode of padding (default: {'same'})
strides {tuple} -- stride of convolution operation (default: {(1, 1, 1)})
activation {str} -- activation function (default: {'relu'})
name {str} -- name of the layer (default: {None})
Returns:
[keras layer] -- [output layer]
'''
x = Conv3D(filters, (num_row, num_col, num_z), strides=strides, padding=padding, use_bias=False)(x)
x = BatchNormalization(axis=4, scale=False)(x)
if(activation==None):
return x
x = Activation(activation, name=name)(x)
return x
示例14: conv_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [as 別名]
def conv_layer_3D(input, neurons, ba_norm, strides=1):
conv = Conv3D(neurons, (3,3,3), activation='relu', padding='same',
strides=strides)(input)
if ba_norm : conv = BatchNormalization(momentum=0.99)(conv)
return conv
示例15: contracting_layer_3D
# 需要導入模塊: from tensorflow.keras import layers [as 別名]
# 或者: from tensorflow.keras.layers import Conv3D [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)
pool = MaxPooling3D(pool_size=(2, 2, 2))(conv2)
return pool, conv2
# Create the middle layer between the contracting and expanding layers