From a226835ed0bfaedd454f40f5e9ecd16f2d6bd424 Mon Sep 17 00:00:00 2001 From: Gabriel Rasskin <43894452+grasskin@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:20:20 -0700 Subject: [PATCH] Migrate np namespace to np 2.0 (#20049) --- keras/src/callbacks/model_checkpoint.py | 8 ++++---- keras/src/callbacks/reduce_lr_on_plateau.py | 4 ++-- keras/src/utils/sequence_utils.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/keras/src/callbacks/model_checkpoint.py b/keras/src/callbacks/model_checkpoint.py index b602fe4403d..24a0110f292 100644 --- a/keras/src/callbacks/model_checkpoint.py +++ b/keras/src/callbacks/model_checkpoint.py @@ -157,20 +157,20 @@ def __init__( if mode == "min": self.monitor_op = np.less if self.best is None: - self.best = np.Inf + self.best = np.inf elif mode == "max": self.monitor_op = np.greater if self.best is None: - self.best = -np.Inf + self.best = -np.inf else: if "acc" in self.monitor or self.monitor.startswith("fmeasure"): self.monitor_op = np.greater if self.best is None: - self.best = -np.Inf + self.best = -np.inf else: self.monitor_op = np.less if self.best is None: - self.best = np.Inf + self.best = np.inf if self.save_freq != "epoch" and not isinstance(self.save_freq, int): raise ValueError( diff --git a/keras/src/callbacks/reduce_lr_on_plateau.py b/keras/src/callbacks/reduce_lr_on_plateau.py index d1ee33e34e1..04c1076f2e1 100644 --- a/keras/src/callbacks/reduce_lr_on_plateau.py +++ b/keras/src/callbacks/reduce_lr_on_plateau.py @@ -92,10 +92,10 @@ def _reset(self): self.mode == "auto" and "acc" not in self.monitor ): self.monitor_op = lambda a, b: np.less(a, b - self.min_delta) - self.best = np.Inf + self.best = np.inf else: self.monitor_op = lambda a, b: np.greater(a, b + self.min_delta) - self.best = -np.Inf + self.best = -np.inf self.cooldown_counter = 0 self.wait = 0 diff --git a/keras/src/utils/sequence_utils.py b/keras/src/utils/sequence_utils.py index 57b72cf78e1..3caf429e192 100644 --- a/keras/src/utils/sequence_utils.py +++ b/keras/src/utils/sequence_utils.py @@ -101,7 +101,7 @@ def pad_sequences( maxlen = np.max(lengths) is_dtype_str = np.issubdtype(dtype, np.str_) or np.issubdtype( - dtype, np.unicode_ + dtype, np.str_ ) if isinstance(value, str) and dtype != object and not is_dtype_str: raise ValueError(