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?
Think about model size and speed for mobile devices.
MobileNetV2 is optimized for mobile devices with fewer parameters and faster inference, making it ideal for limited resources.
What is the output shape of the last layer of the VGG16 model loaded with include_top=True for ImageNet classification?
import tensorflow as tf model = tf.keras.applications.VGG16(include_top=True) output_shape = model.output_shape print(output_shape)
Consider the final classification layer output for ImageNet classes.
With include_top=True, VGG16 ends with a Dense layer of 1000 units for ImageNet classes, so output shape is (None, 1000).
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?
Check the standard input size for ResNet50 trained on ImageNet.
ResNet50 expects input images of size 224x224 pixels as it was trained on ImageNet with this size.
You fine-tune MobileNetV2 on a small dataset and want to evaluate its performance. Which metric is most appropriate to measure classification accuracy?
Think about the type of problem: classification or regression.
Accuracy measures the proportion of correct predictions in classification tasks, which fits fine-tuning MobileNetV2 for classification.
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?
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)
Check the shape of the output tensor from the convolutional base.
When include_top=False, the model output is a 4D tensor. Dense layers require 2D input, so you must flatten or pool before Dense.