Skip to content

Commit 04ebf72

Browse files
authored
Make code compatible with Numpy >= 2.1. (#21032)
Starting with 2.1, the first argument of `np.reshape` is positional only. Removed keyword `a` and for consistency did the same with other backends.
1 parent 8a7955f commit 04ebf72

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

keras/src/backend/jax/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def affine_transform(
465465
# transform the indices
466466
coordinates = jnp.einsum("Bhwij, Bjk -> Bhwik", indices, transform)
467467
coordinates = jnp.moveaxis(coordinates, source=-1, destination=1)
468-
coordinates += jnp.reshape(a=offset, shape=(*offset.shape, 1, 1, 1))
468+
coordinates += jnp.reshape(offset, shape=(*offset.shape, 1, 1, 1))
469469

470470
# apply affine transformation
471471
_map_coordinates = functools.partial(

keras/src/backend/numpy/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def affine_transform(
600600
# transform the indices
601601
coordinates = np.einsum("Bhwij, Bjk -> Bhwik", indices, transform)
602602
coordinates = np.moveaxis(coordinates, source=-1, destination=1)
603-
coordinates += np.reshape(a=offset, newshape=(*offset.shape, 1, 1, 1))
603+
coordinates += np.reshape(offset, newshape=(*offset.shape, 1, 1, 1))
604604

605605
# apply affine transformation
606606
affined = np.stack(

keras/src/backend/torch/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def affine_transform(
424424
# transform the indices
425425
coordinates = torch.einsum("Bhwij, Bjk -> Bhwik", indices, transform)
426426
coordinates = torch.moveaxis(coordinates, source=-1, destination=1)
427-
coordinates += torch.reshape(a=offset, shape=(*offset.shape, 1, 1, 1))
427+
coordinates += torch.reshape(offset, shape=(*offset.shape, 1, 1, 1))
428428

429429
# Note: torch.stack is faster than torch.vmap when the batch size is small.
430430
affined = torch.stack(

0 commit comments

Comments
 (0)