Challenge - 5 Problems
Model Summary Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of model.summary() for a simple CNN
Consider this TensorFlow Keras model:
What is the total number of trainable parameters shown in the summary?
model = tf.keras.Sequential([ tf.keras.layers.Conv2D(16, 3, activation='relu', input_shape=(28,28,1)), tf.keras.layers.MaxPooling2D(2), tf.keras.layers.Flatten(), tf.keras.layers.Dense(10, activation='softmax') ]) model.summary()
What is the total number of trainable parameters shown in the summary?
TensorFlow
import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.Conv2D(16, 3, activation='relu', input_shape=(28,28,1)), tf.keras.layers.MaxPooling2D(2), tf.keras.layers.Flatten(), tf.keras.layers.Dense(10, activation='softmax') ]) model.summary()
Attempts:
2 left
💡 Hint
Calculate parameters for Conv2D: (kernel_height * kernel_width * input_channels + bias) * filters, then add Dense layer params.
✗ Incorrect
Conv2D layer has (3*3*1 + 1) * 16 = 160 parameters. Flatten layer has no parameters. Dense layer has (13*13*16)*10 + 10 = 27050 parameters. MaxPooling reduces spatial size from 26x26 to 13x13. Total parameters = 160 + 27050 = 27210.
🧠 Conceptual
intermediate1:00remaining
Purpose of model.summary() in TensorFlow
What is the main purpose of calling
model.summary() in TensorFlow Keras?Attempts:
2 left
💡 Hint
Think about what information you get immediately after building a model.
✗ Incorrect
model.summary() prints a table showing each layer's name, output shape, and number of parameters. It helps understand model complexity before training.❓ Model Choice
advanced1:30remaining
Choosing the correct code to visualize a model architecture
Which code snippet correctly generates a plot image file named 'model_plot.png' that visualizes the TensorFlow Keras model architecture?
TensorFlow
import tensorflow as tf from tensorflow.keras.utils import plot_model model = tf.keras.Sequential([ tf.keras.layers.Dense(32, input_shape=(10,), activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid') ])
Attempts:
2 left
💡 Hint
Look for the utility function designed for plotting models in Keras.
✗ Incorrect
The function
plot_model from tensorflow.keras.utils is used to create a visualization image file of the model. Other options are invalid or do not exist.❓ Metrics
advanced1:00remaining
Interpreting model.summary() output for parameter counts
In the model summary output, what does the 'Param #' column represent for each layer?
Attempts:
2 left
💡 Hint
Think about what parameters include in neural networks.
✗ Incorrect
The 'Param #' column shows the total parameters including weights and biases, both trainable and non-trainable if any, for each layer.
🔧 Debug
expert2:30remaining
Diagnosing why plot_model does not generate an image
You run this code:
But no image file is created and no error is shown. What is the most likely cause?
from tensorflow.keras.utils import plot_model plot_model(model, to_file='model.png', show_shapes=True)
But no image file is created and no error is shown. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if external dependencies for plotting are installed.
✗ Incorrect
plot_model requires Graphviz and pydot to generate images. If missing, no file is created but no error is raised.