Convolutional Neaural Network Getting Last 4 Layers

Viewed 25

I would like to ask about my code below.

I would like to get last for layers when include_top=False.

First part, there is no any problem here:

from tensorflow.keras.applications.mobilenet import MobileNet
from tensorflow.keras.layers import Input
from tensorflow.keras.models import Model
from keras.layers import Flatten, Activation, Dense, Dropout, Reshape
from keras.preprocessing.image import ImageDataGenerator
from keras import backend as K
from PIL import Image

imageWidth, imageHeight = 224, 224

imageChannels = 3
batchSize = 1
epoch = 1 
classMode = 'categorical'

fcDense = 4

fcActivation = 'softmax'
optimizer = 'adam'
loss = 'binary_crossentropy'
metrics = 'accuracy'

train_data_yolu = 'data/train'
validation_data_yolu = 'data/validation'

if K.image_data_format() == 'channes_first':
    input_shape = (3, imageWidth, imageHeight)
else:
    input_shape = (imageWidth, imageHeight, 3)

train_ornek_sayisi = 30
validation_ornek_sayisi = 30

Second part which I want to change the summary : As you see below when include_top=True i can get last 4 layers.

model = MobileNet(include_top=True, weights='imagenet')
model.summary()

When include_top=True, I can see these; But I want to get same result when include_top=False.

 global_average_pooling2d_9   (None, 1, 1, 1024)       0         
 (GlobalAveragePooling2D)                                        
                                                                 
 dropout (Dropout)           (None, 1, 1, 1024)        0         
                                                                 
 conv_preds (Conv2D)         (None, 1, 1, 1000)        1025000   
                                                                 
 reshape_2 (Reshape)         (None, 1000)              0         
                                                                 
 predictions (Activation)    (None, 1000)              0    
0 Answers
Related