Skip to content

Commit

Permalink
Merge branch 'master' of github.com:keras-team/keras
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Jan 20, 2024
2 parents ea38ae3 + 07500c3 commit 19187d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions keras/backend/torch/numpy.py
Expand Up @@ -892,9 +892,7 @@ def min(x, axis=None, keepdims=False, initial=None):
if axis is None:
result = torch.min(x)
else:
if isinstance(axis, list):
axis = axis[-1]
result = torch.min(x, dim=axis, keepdim=keepdims)
result = amin(x, axis=axis, keepdims=keepdims)

if isinstance(getattr(result, "values", None), torch.Tensor):
result = result.values
Expand Down
6 changes: 6 additions & 0 deletions keras/ops/numpy_test.py
Expand Up @@ -3429,6 +3429,12 @@ def test_min(self):
self.assertAllClose(knp.min(x), np.min(x))
self.assertAllClose(knp.Min()(x), np.min(x))

self.assertAllClose(knp.min(x, axis=(0, 1)), np.min(x, (0, 1)))
self.assertAllClose(knp.Min((0, 1))(x), np.min(x, (0, 1)))

self.assertAllClose(knp.min(x, axis=()), np.min(x, axis=()))
self.assertAllClose(knp.Min(())(x), np.min(x, axis=()))

self.assertAllClose(knp.min(x, 0), np.min(x, 0))
self.assertAllClose(knp.Min(0)(x), np.min(x, 0))

Expand Down

0 comments on commit 19187d8

Please sign in to comment.