diff --git a/keras/src/trainers/compile_utils.py b/keras/src/trainers/compile_utils.py index 5678f8cba15..afb31ed716b 100644 --- a/keras/src/trainers/compile_utils.py +++ b/keras/src/trainers/compile_utils.py @@ -164,7 +164,7 @@ def variables(self): if not self.built: return [] vars = [] - for m in self._flat_metrics + self._flat_weighted_metrics: + for m in self.metrics: if m is not None: vars.extend(m.variables) return vars