0
0
TensorFlowml~20 mins

Model summary and visualization in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Model Summary Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of model.summary() for a simple CNN
Consider this TensorFlow Keras model:
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()
A27210
B14890
C15000
D14796
Attempts:
2 left
💡 Hint
Calculate parameters for Conv2D: (kernel_height * kernel_width * input_channels + bias) * filters, then add Dense layer params.
🧠 Conceptual
intermediate
1:00remaining
Purpose of model.summary() in TensorFlow
What is the main purpose of calling model.summary() in TensorFlow Keras?
ATo visualize the training loss and accuracy graphs
BTo print a detailed layer-by-layer description including output shapes and parameter counts
CTo save the model architecture to a file
DTo train the model on the dataset
Attempts:
2 left
💡 Hint
Think about what information you get immediately after building a model.
Model Choice
advanced
1: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')
])
Aplot_model(model, to_file='model_plot.png', show_shapes=True)
Bmodel.save('model_plot.png')
Cmodel.plot('model_plot.png')
Dplot(model, filename='model_plot.png')
Attempts:
2 left
💡 Hint
Look for the utility function designed for plotting models in Keras.
Metrics
advanced
1:00remaining
Interpreting model.summary() output for parameter counts
In the model summary output, what does the 'Param #' column represent for each layer?
AThe number of input features to that layer
BOnly the number of trainable parameters in that layer
CThe total number of trainable and non-trainable parameters in that layer
DThe number of output neurons in that layer
Attempts:
2 left
💡 Hint
Think about what parameters include in neural networks.
🔧 Debug
expert
2:30remaining
Diagnosing why plot_model does not generate an image
You run this code:
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?
AThe model variable is not defined
BThe to_file parameter must be an absolute path
Cshow_shapes=True causes the function to fail silently
DGraphviz or pydot package is not installed or not configured properly
Attempts:
2 left
💡 Hint
Check if external dependencies for plotting are installed.