Complete the code to load the VGG16 pre-trained model without the top classification layer.
from tensorflow.keras.applications import VGG16 model = VGG16(include_top=[1], weights='imagenet')
Setting include_top=False loads the model without the final classification layers, useful for feature extraction.
Complete the code to preprocess input images for ResNet50 model.
from tensorflow.keras.applications.resnet50 import preprocess_input preprocessed_img = preprocess_input([1])
The preprocess_input function expects raw image data to prepare it for the model.
Fix the error in the code to correctly load MobileNet with input shape 128x128x3.
from tensorflow.keras.applications import MobileNet model = MobileNet(input_shape=[1], weights='imagenet', include_top=False)
The input_shape argument requires a tuple specifying the dimensions.
Fill both blanks to create a feature extractor from ResNet50 and freeze its layers.
from tensorflow.keras.applications import ResNet50 model = ResNet50(include_top=[1], weights='imagenet') model.[2] = False
Setting include_top=False removes the classification layers. Setting model.trainable = False freezes the model weights.
Fill all three blanks to build a simple classifier on top of MobileNet features.
from tensorflow.keras.applications import MobileNet from tensorflow.keras import layers, models base_model = MobileNet(include_top=[1], weights='imagenet', input_shape=(224,224,3)) base_model.trainable = [2] model = models.Sequential([ base_model, layers.GlobalAveragePooling2D(), layers.Dense([3], activation='softmax') ])
We exclude the top layer (include_top=False) to add our own classifier. We freeze the base model (trainable=False) to keep pre-trained weights fixed. The final Dense layer has 10 units for 10 classes.