0
$\begingroup$

I want to do a multiclass segmentation task using deep learning (in python). Here, is a summary of vgg_unet model that is mainly collected from GitHub. So, in my dataset 8 labels are available. So, at the last convolution layer, there are 8 channels for the categorical classification of every class. The summary of my model is here,

__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None, 512, 512, 3) 0                                            
__________________________________________________________________________________________________
block1_conv1 (Conv2D)           (None, 512, 512, 64) 1792        input_1[0][0]                    
__________________________________________________________________________________________________
block1_conv2 (Conv2D)           (None, 512, 512, 64) 36928       block1_conv1[0][0]               
__________________________________________________________________________________________________
block1_pool (MaxPooling2D)      (None, 256, 256, 64) 0           block1_conv2[0][0]               
__________________________________________________________________________________________________
block2_conv1 (Conv2D)           (None, 256, 256, 128 73856       block1_pool[0][0]                
__________________________________________________________________________________________________
block2_conv2 (Conv2D)           (None, 256, 256, 128 147584      block2_conv1[0][0]               
__________________________________________________________________________________________________
block2_pool (MaxPooling2D)      (None, 128, 128, 128 0           block2_conv2[0][0]               
__________________________________________________________________________________________________
block3_conv1 (Conv2D)           (None, 128, 128, 256 295168      block2_pool[0][0]                
__________________________________________________________________________________________________
block3_conv2 (Conv2D)           (None, 128, 128, 256 590080      block3_conv1[0][0]               
__________________________________________________________________________________________________
block3_conv3 (Conv2D)           (None, 128, 128, 256 590080      block3_conv2[0][0]               
__________________________________________________________________________________________________
block3_pool (MaxPooling2D)      (None, 64, 64, 256)  0           block3_conv3[0][0]               
__________________________________________________________________________________________________
block4_conv1 (Conv2D)           (None, 64, 64, 512)  1180160     block3_pool[0][0]                
__________________________________________________________________________________________________
block4_conv2 (Conv2D)           (None, 64, 64, 512)  2359808     block4_conv1[0][0]               
__________________________________________________________________________________________________
block4_conv3 (Conv2D)           (None, 64, 64, 512)  2359808     block4_conv2[0][0]               
__________________________________________________________________________________________________
block4_pool (MaxPooling2D)      (None, 32, 32, 512)  0           block4_conv3[0][0]               
__________________________________________________________________________________________________
zero_padding2d (ZeroPadding2D)  (None, 34, 34, 512)  0           block4_pool[0][0]                
__________________________________________________________________________________________________
conv2d (Conv2D)                 (None, 32, 32, 512)  2359808     zero_padding2d[0][0]             
__________________________________________________________________________________________________
batch_normalization (BatchNorma (None, 32, 32, 512)  2048        conv2d[0][0]                     
__________________________________________________________________________________________________
up_sampling2d (UpSampling2D)    (None, 64, 64, 512)  0           batch_normalization[0][0]        
__________________________________________________________________________________________________
concatenate (Concatenate)       (None, 64, 64, 768)  0           up_sampling2d[0][0]              
                                                                 block3_pool[0][0]                
__________________________________________________________________________________________________
zero_padding2d_1 (ZeroPadding2D (None, 66, 66, 768)  0           concatenate[0][0]                
__________________________________________________________________________________________________
conv2d_1 (Conv2D)               (None, 64, 64, 256)  1769728     zero_padding2d_1[0][0]           
__________________________________________________________________________________________________
batch_normalization_1 (BatchNor (None, 64, 64, 256)  1024        conv2d_1[0][0]                   
__________________________________________________________________________________________________
up_sampling2d_1 (UpSampling2D)  (None, 128, 128, 256 0           batch_normalization_1[0][0]      
__________________________________________________________________________________________________
concatenate_1 (Concatenate)     (None, 128, 128, 384 0           up_sampling2d_1[0][0]            
                                                                 block2_pool[0][0]                
__________________________________________________________________________________________________
zero_padding2d_2 (ZeroPadding2D (None, 130, 130, 384 0           concatenate_1[0][0]              
__________________________________________________________________________________________________
conv2d_2 (Conv2D)               (None, 128, 128, 128 442496      zero_padding2d_2[0][0]           
__________________________________________________________________________________________________
batch_normalization_2 (BatchNor (None, 128, 128, 128 512         conv2d_2[0][0]                   
__________________________________________________________________________________________________
up_sampling2d_2 (UpSampling2D)  (None, 256, 256, 128 0           batch_normalization_2[0][0]      
__________________________________________________________________________________________________
concatenate_2 (Concatenate)     (None, 256, 256, 192 0           up_sampling2d_2[0][0]            
                                                                 block1_pool[0][0]                
__________________________________________________________________________________________________
zero_padding2d_3 (ZeroPadding2D (None, 258, 258, 192 0           concatenate_2[0][0]              
__________________________________________________________________________________________________
conv2d_3 (Conv2D)               (None, 256, 256, 64) 110656      zero_padding2d_3[0][0]           
__________________________________________________________________________________________________
batch_normalization_3 (BatchNor (None, 256, 256, 64) 256         conv2d_3[0][0]                   
__________________________________________________________________________________________________
up_sampling2d_3 (UpSampling2D)  (None, 512, 512, 64) 0           batch_normalization_3[0][0]      
__________________________________________________________________________________________________
conv2d_4 (Conv2D)               (None, 512, 512, 64) 36928       up_sampling2d_3[0][0]            
__________________________________________________________________________________________________
batch_normalization_4 (BatchNor (None, 512, 512, 64) 256         conv2d_4[0][0]                   
__________________________________________________________________________________________________
conv2d_5 (Conv2D)               (None, 512, 512, 8)  4616        batch_normalization_4[0][0]      
__________________________________________________________________________________________________
activation (Activation)         (None, 512, 512, 8)  0           conv2d_5[0][0]                   
==================================================================================================
Total params: 12,363,592
Trainable params: 12,361,544
Non-trainable params: 2,048
__________________________________________________________________________________________________

But, in the main GitHub page he, reshape the output of conv2d_5 layer (last convolution layer in my model) to a single dimension, that is given below.

__________________________________________________________________________________________________
conv2d_5 (Conv2D)               (None, 512, 512, 8)  4616        batch_normalization_4[0][0]      
__________________________________________________________________________________________________
reshape (Reshape)               (None, 262144, None) 0           conv2d_5[0][0]                   
__________________________________________________________________________________________________
activation (Activation)         (None, 262144, None) 0           reshape[0][0]                    
==================================================================================================  

My question is why this type of reshaping is used here and what is its purpose and benefit? Also when I predict and visualize any image I need to reshape it to (512,512,8) and further processed it. So, what is the benefit such type of reshaping(reshape layer in the above summary) and if I don't use this reshape what will the drawback in my model?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.