However, in the case of the BatchNormalization
layer, setting
trainable = False
on the layer means that the layer will be
subsequently run in inference mode (meaning that it will use
the moving mean and the moving variance to normalize the current batch,
rather than using the mean and variance of the current batch).
def _get_training_value(self, training=None):
if training is None:
training = backend.learning_phase()
if self._USE_V2_BEHAVIOR:
if isinstance(training, int):
training = bool(training)
if not self.trainable:
# When the layer is not trainable, it overrides the value passed from
# model.
training = False
return training