0
0
TensorFlowml~20 mins

Pre-trained models (VGG, ResNet, MobileNet) in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pre-trained Models Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Model Choice
intermediate
2:00remaining
Choosing the right pre-trained model for image classification

You want to classify images of everyday objects on a mobile device with limited memory and processing power. Which pre-trained model is the best choice?

AVGG16 - It has a very deep architecture but is large and slow.
BMobileNetV2 - It is designed for mobile and embedded devices with low latency.
CResNet50 - It uses residual connections and is moderately sized.
DInceptionV3 - It has complex modules and is computationally heavy.
Attempts:
2 left
💡 Hint

Think about model size and speed for mobile devices.

Predict Output
intermediate
2:00remaining
Output shape of a pre-trained VGG16 model

What is the output shape of the last layer of the VGG16 model loaded with include_top=True for ImageNet classification?

TensorFlow
import tensorflow as tf
model = tf.keras.applications.VGG16(include_top=True)
output_shape = model.output_shape
print(output_shape)
A(None, 7, 7, 512)
B(None, 224, 224, 3)
C(None, 1000)
D(None, 4096)
Attempts:
2 left
💡 Hint

Consider the final classification layer output for ImageNet classes.

Hyperparameter
advanced
2:00remaining
Choosing the correct input size for ResNet50

You want to use the pre-trained ResNet50 model from TensorFlow Keras applications. What is the correct input image size to feed into this model?

A128x128 pixels
B299x299 pixels
C64x64 pixels
D224x224 pixels
Attempts:
2 left
💡 Hint

Check the standard input size for ResNet50 trained on ImageNet.

Metrics
advanced
2:00remaining
Evaluating MobileNetV2 performance on a custom dataset

You fine-tune MobileNetV2 on a small dataset and want to evaluate its performance. Which metric is most appropriate to measure classification accuracy?

AAccuracy
BMean Squared Error (MSE)
CMean Absolute Error (MAE)
DRoot Mean Squared Error (RMSE)
Attempts:
2 left
💡 Hint

Think about the type of problem: classification or regression.

🔧 Debug
expert
3:00remaining
Debugging a shape mismatch error with ResNet50

You load ResNet50 with include_top=False and try to add a Dense layer with 1000 units directly after the model output. You get a shape mismatch error. Why?

TensorFlow
import tensorflow as tf
base_model = tf.keras.applications.ResNet50(include_top=False, input_shape=(224,224,3))
x = base_model.output
output = tf.keras.layers.Dense(1000, activation='softmax')(x)
model = tf.keras.Model(inputs=base_model.input, outputs=output)
AThe output of base_model is 4D (batch, height, width, channels), but Dense expects 2D input.
BThe input shape is incorrect; ResNet50 requires 299x299 images.
CDense layer cannot have 1000 units after a convolutional base.
DYou must set include_top=True to add Dense layers.
Attempts:
2 left
💡 Hint

Check the shape of the output tensor from the convolutional base.