What does it mean to 'freeze' layers in a neural network?
Freezing layers means making their weights unchangeable during training. This keeps the learned features intact while training other parts of the model.
Click to reveal answer
beginner
Why would you freeze layers when using transfer learning?
You freeze layers to keep the useful features learned from a large dataset and only train new layers for your specific task. This saves time and avoids losing good features.
Click to reveal answer
beginner
How do you freeze layers in TensorFlow Keras?
Set the layer's 'trainable' property to False, for example: layer.trainable = False. Then recompile and train the model.
Click to reveal answer
intermediate
What does 'unfreezing' layers mean and when is it useful?
Unfreezing means allowing previously frozen layers to update their weights during training. It is useful for fine-tuning the whole model after initial training.
Click to reveal answer
intermediate
What is a common workflow involving freezing and unfreezing layers?
First, freeze base layers and train new layers. Then unfreeze some or all base layers and continue training with a low learning rate to fine-tune.
Click to reveal answer
What happens when you set layer.trainable = False in TensorFlow?
AThe layer's weights do not update during training
BThe layer's weights are reset to zero
CThe layer is removed from the model
DThe layer trains faster
✗ Incorrect
Setting layer.trainable = False freezes the layer so its weights stay fixed during training.
Why freeze layers in transfer learning?
ATo make the model smaller
BTo speed up data loading
CTo keep learned features and avoid retraining all layers
DTo increase the number of layers
✗ Incorrect
Freezing layers keeps the useful features learned from previous data and focuses training on new layers.
When is unfreezing layers most useful?
ABefore compiling the model
BDuring fine-tuning after initial training
CWhen initializing the model
DWhen saving the model
✗ Incorrect
Unfreezing allows updating weights to fine-tune the model after training new layers.
What must you do after changing layer.trainable before training?
ARecompile the model
BRestart Python
CSave the model
DNothing, just train
✗ Incorrect
You must recompile the model so the training configuration updates with the new trainable settings.
Which is a typical step in freezing and unfreezing workflow?
AFreeze all layers and never train
BUnfreeze all layers at the start
CTrain only frozen layers
DFreeze base layers, train new layers, then unfreeze base layers for fine-tuning
✗ Incorrect
This workflow helps keep learned features and then fine-tunes the whole model carefully.
Explain the concept of freezing and unfreezing layers in neural networks and why it is important in transfer learning.
Think about keeping learned features fixed vs. updating them.
You got /4 concepts.
Describe the steps to freeze and then unfreeze layers in a TensorFlow Keras model during training.
Remember to recompile after changing trainable status.
You got /6 concepts.
Practice
(1/5)
1. What does freezing layers in a TensorFlow model do?
easy
A. Stops the layers from updating their weights during training
B. Allows the layers to learn new features
C. Deletes the layers from the model
D. Increases the learning rate for those layers
Solution
Step 1: Understand the meaning of freezing layers
Freezing layers means preventing them from changing their weights during training.
Step 2: Identify the effect of freezing
Since weights do not update, the layers keep their learned knowledge intact.
Final Answer:
Stops the layers from updating their weights during training -> Option A
Quick Check:
Freezing = stop weight updates [OK]
Hint: Freezing means no weight updates during training [OK]
Common Mistakes:
Thinking freezing deletes layers
Believing freezing increases learning rate
Confusing freezing with unfreezing
2. Which is the correct way to freeze a layer named layer in TensorFlow before compiling the model?
easy
A. layer.frozen = True
B. layer.freeze = True
C. layer.trainable = True
D. layer.trainable = False
Solution
Step 1: Recall the attribute to control training
TensorFlow uses the trainable attribute to allow or prevent training on layers.
Step 2: Set the attribute to freeze
Setting trainable = False freezes the layer so it won't update during training.
Final Answer:
layer.trainable = False -> Option D
Quick Check:
Freeze layer = trainable False [OK]
Hint: Use trainable = False to freeze layers before compile [OK]
Common Mistakes:
Using non-existent attributes like freeze or frozen
Setting trainable = True to freeze
Changing trainable after compiling
3. Given the code below, what will be the output of model.layers[0].trainable after compiling?