Skip to content

Commit

Permalink
Migrate np namespace to np 2.0 (#20049)
Browse files Browse the repository at this point in the history
  • Loading branch information
grasskin authored Jul 26, 2024
1 parent 7d92e9e commit a226835
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions keras/src/callbacks/model_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions keras/src/callbacks/reduce_lr_on_plateau.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion keras/src/utils/sequence_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a226835

Please sign in to comment.