【发布时间】:2021-11-02 02:31:30
【问题描述】:
我的 U-Net 模型
def unet_model(input_size=(96, 128, 3), n_filters=32, n_classes=23):
"""
Unet model
Arguments:
input_size -- Input shape
n_filters -- Number of filters for the convolutional layers
n_classes -- Number of output classes
Returns:
model -- tf.keras.Model
"""
inputs = Input(input_size)
# Contracting Path (encoding)
# Add a conv_block with the inputs of the unet_ model and n_filters
### START CODE HERE
cblock1 = conv_block(inputs, n_filters)
# Chain the first element of the output of each block to be the input of the next conv_block.
# Double the number of filters at each new step
cblock2 = conv_block(cblock1[0], n_filters*2)
cblock3 = conv_block(cblock2[0], n_filters*4)
cblock4 = conv_block(cblock3[0], n_filters*8, dropout_prob=0.3) # Include a dropout_prob of 0.3 for this layer
# Include a dropout_prob of 0.3 for this layer, and avoid the max_pooling layer
cblock5 = conv_block(cblock4[0], n_filters*16, dropout_prob=0.3, max_pooling=False)
### END CODE HERE
# Expanding Path (decoding)
# Add the first upsampling_block.
# Use the cblock5[0] as expansive_input and cblock4[1] as contractive_input and n_filters * 8
### START CODE HERE
ublock6 = upsampling_block(cblock5[0], cblock4[1], n_filters*8)
# Chain the output of the previous block as expansive_input and the corresponding contractive block output.
# Note that you must use the second element of the contractive block i.e before the maxpooling layer.
# At each step, use half the number of filters of the previous block
ublock7 = upsampling_block(ublock6[0], cblock5[0], n_filters*4)
ublock8 = upsampling_block(ublock7[0], ublock6[0], n_filters*2)
ublock9 = upsampling_block(ublock8[0], ublock7[0], n_filters)
### END CODE HERE
conv9 = Conv2D(n_filters,
3,
activation='relu',
padding='same',
kernel_initializer='he_normal')(ublock9)
# Add a Conv2D layer with n_classes filter, kernel size of 1 and a 'same' padding
### START CODE HERE
conv10 = Conv2D(n_filters, 1 , padding='same')(conv9)
### END CODE HERE
model = tf.keras.Model(inputs=inputs, outputs=conv10)
return model
... 在上述 Unet 模型中,模型的前半部分已完成,即直到 cblock5 但是从模型的后半部分,即从 cblock6 到 cblock9 我有点困惑 ...
# 将前一个块的输出链接为 expansive_input 和相应的收缩块输出。
# 请注意,您必须使用收缩块的第二个元素,即在 maxpooling 层之前。
# 在每一步,使用前一个块的一半过滤器数量
... 请帮我理解上述指令的含义。 ...
【问题讨论】:
-
他可能要求你创建残差块,并创建编码和解码块
标签: conv-neural-network image-segmentation