How come we have to re-compile the model after setting the trainable property of layer(s) = False, but not when setting them to True?
Under the "Training Multiple Layers in Keras" section In the lesson 2 notebook there is this code ...
layers = model.layers
# Get the index of the first dense layer...
first_dense_idx = [index for index,layer in enumerate(layers) if type(layer) is Dense]
# ...and set this and all subsequent layers to trainable
for layer in layers[first_dense_idx:]: layer.trainable=True
... and then the comment ...
Since we haven't changed our architecture, there's no need to re-compile the model - instead, we just set the learning rate. Since we're training more layers, and since we've already optimized the last layer, we should use a lower learning rate than previously.
But the Keras documentation says:
Additionally, you can set the trainable property of a layer to True or False after instantiation. For this to take effect, you will need to call compile() on your model after modifying the trainable property.
So I'm confused. The Keras docs seem to indicate that the model needs to be compiled anytime the trainable property of it's layer(s) are changed ... whereas the comment in the notebook seems to indicate this isn't the case if you are setting the property to True.