0
0
TensorFlowml~10 mins

Pre-trained models (VGG, ResNet, MobileNet) in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load the VGG16 pre-trained model without the top classification layer.

TensorFlow
from tensorflow.keras.applications import VGG16
model = VGG16(include_top=[1], weights='imagenet')
Drag options to blanks, or click blank then click option'
ATrue
B'imagenet'
CFalse
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using include_top=True when you want to customize the output.
Passing weights=None instead of 'imagenet'.
2fill in blank
medium

Complete the code to preprocess input images for ResNet50 model.

TensorFlow
from tensorflow.keras.applications.resnet50 import preprocess_input
preprocessed_img = preprocess_input([1])
Drag options to blanks, or click blank then click option'
Araw_image
Bmodel
Cinput_shape
Dpredictions
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the model object instead of image data.
Passing predictions instead of raw images.
3fill in blank
hard

Fix the error in the code to correctly load MobileNet with input shape 128x128x3.

TensorFlow
from tensorflow.keras.applications import MobileNet
model = MobileNet(input_shape=[1], weights='imagenet', include_top=False)
Drag options to blanks, or click blank then click option'
A(128, 128, 3)
B[128, 128, 3]
C128, 128, 3
D'128x128x3'
Attempts:
3 left
💡 Hint
Common Mistakes
Using list brackets instead of tuple parentheses.
Passing a string instead of a tuple.
4fill in blank
hard

Fill both blanks to create a feature extractor from ResNet50 and freeze its layers.

TensorFlow
from tensorflow.keras.applications import ResNet50
model = ResNet50(include_top=[1], weights='imagenet')
model.[2] = False
Drag options to blanks, or click blank then click option'
AFalse
BTrue
Ctrainable
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using include_top=True when freezing layers.
Trying to freeze layers by calling compile instead of setting trainable.
5fill in blank
hard

Fill all three blanks to build a simple classifier on top of MobileNet features.

TensorFlow
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')
])
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C10
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Setting include_top=True when adding custom layers.
Not freezing the base model causing slow training.
Using None instead of number of classes in Dense layer.