keras-nightly 3.14.0.dev2026013104__py3-none-any.whl → 3.14.0.dev2026020104__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import builtins
2
2
  import math
3
3
 
4
+ import jax
4
5
  import jax.experimental.sparse as jax_sparse
5
6
  import jax.numpy as jnp
6
7
  from jax import export as jax_export
@@ -16,6 +17,18 @@ from keras.src.backend.jax.core import cast
16
17
  from keras.src.backend.jax.core import convert_to_tensor
17
18
 
18
19
 
20
+ def _uses_cpu(x):
21
+ if hasattr(x, "device"):
22
+ device = x.device
23
+ if not isinstance(device, jax.Device):
24
+ # Array is sharded.
25
+ return False
26
+ return device.platform == "cpu"
27
+ else:
28
+ # This is a Tracer, not a concrete Array.
29
+ return jax.default_backend() == "cpu"
30
+
31
+
19
32
  def rot90(array, k=1, axes=(0, 1)):
20
33
  """Rotate an array by 90 degrees in the specified plane."""
21
34
  if array.ndim < 2:
@@ -402,11 +415,9 @@ def arctanh(x):
402
415
 
403
416
 
404
417
  def argmax(x, axis=None, keepdims=False):
405
- from keras.src.testing.test_case import uses_cpu
406
-
407
418
  x = convert_to_tensor(x)
408
419
  dtype = standardize_dtype(x.dtype)
409
- if "float" not in dtype or not uses_cpu() or x.ndim == 0:
420
+ if "float" not in dtype or x.ndim == 0 or not _uses_cpu(x):
410
421
  return jnp.argmax(x, axis=axis, keepdims=keepdims)
411
422
 
412
423
  # Fix the flush-to-zero (FTZ) issue based on this issue:
@@ -419,11 +430,9 @@ def argmax(x, axis=None, keepdims=False):
419
430
 
420
431
 
421
432
  def argmin(x, axis=None, keepdims=False):
422
- from keras.src.testing.test_case import uses_cpu
423
-
424
433
  x = convert_to_tensor(x)
425
434
  dtype = standardize_dtype(x.dtype)
426
- if "float" not in dtype or not uses_cpu() or x.ndim == 0:
435
+ if "float" not in dtype or x.ndim == 0 or not _uses_cpu(x):
427
436
  return jnp.argmin(x, axis=axis, keepdims=keepdims)
428
437
 
429
438
  # Fix the flush-to-zero (FTZ) issue based on this issue:
@@ -366,6 +366,10 @@ def arctan2(x1, x2):
366
366
  x1 = ov_opset.convert(x1, result_type)
367
367
  x2 = ov_opset.convert(x2, result_type)
368
368
 
369
+ nan_x1 = ov_opset.is_nan(x1)
370
+ nan_x2 = ov_opset.is_nan(x2)
371
+ nan_mask = ov_opset.logical_or(nan_x1, nan_x2)
372
+
369
373
  x = ov_opset.divide(x1, x2)
370
374
  y = ov_opset.atan(x)
371
375
 
@@ -375,12 +379,12 @@ def arctan2(x1, x2):
375
379
  neg_half_pi = ov_opset.constant(-float(np.pi / 2), ov_type)
376
380
  zero_const = ov_opset.constant(0.0, ov_type)
377
381
 
378
- cond_x2_gt0 = ov_opset.greater(x2, zero_const).output(0)
379
- cond_x2_lt0 = ov_opset.less(x2, zero_const).output(0)
382
+ cond_x2_gt0 = ov_opset.greater(x2, zero_const)
383
+ cond_x2_lt0 = ov_opset.less(x2, zero_const)
380
384
 
381
- cond_x1_ge0 = ov_opset.greater_equal(x1, zero_const).output(0)
382
- cond_x1_gt0 = ov_opset.greater(x1, zero_const).output(0)
383
- cond_x1_eq0 = ov_opset.equal(x1, zero_const).output(0)
385
+ cond_x1_ge0 = ov_opset.greater_equal(x1, zero_const)
386
+ cond_x1_gt0 = ov_opset.greater(x1, zero_const)
387
+ cond_x1_eq0 = ov_opset.equal(x1, zero_const)
384
388
 
385
389
  out_x2_lt0 = ov_opset.select(
386
390
  cond_x1_ge0,
@@ -393,7 +397,11 @@ def arctan2(x1, x2):
393
397
 
394
398
  out_not_pos = ov_opset.select(cond_x2_lt0, out_x2_lt0, out_x2_zero)
395
399
 
396
- final_out = ov_opset.select(cond_x2_gt0, y, out_not_pos)
400
+ value_out = ov_opset.select(cond_x2_gt0, y, out_not_pos)
401
+
402
+ # Generate NaN safely for all floating dtypes (including bf16)
403
+ nan_value = ov_opset.divide(zero_const, zero_const)
404
+ final_out = ov_opset.select(nan_mask, nan_value, value_out)
397
405
  return OpenVINOKerasTensor(final_out.output(0))
398
406
 
399
407
 
@@ -949,11 +949,9 @@ def argmax(x, axis=None, keepdims=False):
949
949
 
950
950
 
951
951
  def argmin(x, axis=None, keepdims=False):
952
- from keras.src.testing.test_case import uses_cpu
953
-
954
952
  x = convert_to_tensor(x)
955
953
  dtype = standardize_dtype(x.dtype)
956
- if "float" not in dtype or not uses_cpu() or x.ndim == 0:
954
+ if "float" not in dtype or x.ndim == 0:
957
955
  _x = x
958
956
  if axis is None:
959
957
  x = tf.reshape(x, [-1])
keras/src/ops/image.py CHANGED
@@ -342,6 +342,10 @@ def resize(
342
342
  "Expected `size` to be a tuple of 2 integers. "
343
343
  f"Received: size={size}"
344
344
  )
345
+ if size[0] <= 0 or size[1] <= 0:
346
+ raise ValueError(
347
+ f"`size` must have positive height and width. Received: size={size}"
348
+ )
345
349
  if len(images.shape) < 3 or len(images.shape) > 4:
346
350
  raise ValueError(
347
351
  "Invalid images rank: expected rank 3 (single image) "
@@ -1,5 +1,6 @@
1
1
  from keras.src.testing.test_case import TestCase
2
2
  from keras.src.testing.test_case import jax_uses_gpu
3
+ from keras.src.testing.test_case import jax_uses_tpu
3
4
  from keras.src.testing.test_case import tensorflow_uses_gpu
4
5
  from keras.src.testing.test_case import torch_uses_gpu
5
6
  from keras.src.testing.test_case import uses_gpu
@@ -650,6 +650,10 @@ def uses_gpu():
650
650
  return False
651
651
 
652
652
 
653
+ def jax_uses_tpu():
654
+ return backend.backend() == "jax" and uses_tpu()
655
+
656
+
653
657
  def uses_tpu():
654
658
  # Condition used to skip tests when using the TPU
655
659
  try:
@@ -661,13 +665,6 @@ def uses_tpu():
661
665
  return False
662
666
 
663
667
 
664
- def uses_cpu():
665
- devices = distribution.list_devices()
666
- if any(d.startswith("cpu") for d in devices):
667
- return True
668
- return False
669
-
670
-
671
668
  def create_keras_tensors(input_shape, dtype, sparse, ragged):
672
669
  if isinstance(input_shape, dict):
673
670
  return {
keras/src/version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from keras.src.api_export import keras_export
2
2
 
3
3
  # Unique source of truth for the version number.
4
- __version__ = "3.14.0.dev2026013104"
4
+ __version__ = "3.14.0.dev2026020104"
5
5
 
6
6
 
7
7
  @keras_export("keras.version")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keras-nightly
3
- Version: 3.14.0.dev2026013104
3
+ Version: 3.14.0.dev2026020104
4
4
  Summary: Multi-backend Keras
5
5
  Author-email: Keras team <keras-users@googlegroups.com>
6
6
  License: Apache License 2.0
@@ -128,7 +128,7 @@ keras/regularizers/__init__.py,sha256=542Shphw7W8h4Dyf2rmqMKUECVZ8IVBvN9g1LWhz-b
128
128
  keras/saving/__init__.py,sha256=KvL2GZxjvgFgEhvEnkvqjIR9JSNHKz-NWZacXajsjLI,1298
129
129
  keras/src/__init__.py,sha256=Gi4S7EiCMkE03PbdGNpFdaUYySWDs_FcAJ8Taz9Y1BE,684
130
130
  keras/src/api_export.py,sha256=gXOkBOnmscV013WAc75lc4Up01-Kkg9EylIAT_QWctg,1173
131
- keras/src/version.py,sha256=czO9hPDnPlqYI5RCPx-8o5q4MY_U5sszh1qYgRP4csc,204
131
+ keras/src/version.py,sha256=YVXKe5l9tEt9_9bakF2ygI06eoZxA2c62e5pIfrcCDA,204
132
132
  keras/src/activations/__init__.py,sha256=0nL3IFDB9unlrMz8ninKOWo-uCHasTUpTo1tXZb2u44,4433
133
133
  keras/src/activations/activations.py,sha256=mogPggtp4CGldI3VOPNmesRxp6EbiR1_i4KLGaVwzL8,17614
134
134
  keras/src/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -171,7 +171,7 @@ keras/src/backend/jax/layer.py,sha256=o6CicT06udwamTRQIjNSDLZLyYHFzBXNbxewXgWe0i
171
171
  keras/src/backend/jax/linalg.py,sha256=LDaLZYz49ChE2kJR3YpaM9xuwusvd3krV7nNAAazTWA,2642
172
172
  keras/src/backend/jax/math.py,sha256=1IEDpdoF8e5ltu3D4wbDQuihzvJHhMXz8W9Z_E-eJqU,9391
173
173
  keras/src/backend/jax/nn.py,sha256=mrRawNvf9EWe8rdTwK_Auz6xdLkVG6hH0nIAP7hyUDE,60271
174
- keras/src/backend/jax/numpy.py,sha256=9d3zfOWJYO-BaIWXpUi-etaRkwbrb3wzFfjWPOoV9pI,39255
174
+ keras/src/backend/jax/numpy.py,sha256=cfsOw40nf4gcTaiU3LZHY91hjMpa7gORAfcL8rTlbO4,39487
175
175
  keras/src/backend/jax/optimizer.py,sha256=5DeXQHcYmUI6F9i1m1VHn3sBt4LEStOeBXnKdESevLM,4134
176
176
  keras/src/backend/jax/random.py,sha256=Uk2huGIk_dlzMrx5eDVrrr2TeCEMitn2vr4yzA0NXjs,3594
177
177
  keras/src/backend/jax/rnn.py,sha256=Ycq0qfLY4M4jhltvztpLQyywjEM17T7CZQFh4hhHOUE,7767
@@ -198,7 +198,7 @@ keras/src/backend/openvino/layer.py,sha256=5RdvaH1yOyPAphjKiuQAK1H_yZFYKE1Hp7c5b
198
198
  keras/src/backend/openvino/linalg.py,sha256=L6a4MFGND2wWzPVCh44cwuOgkcC4wJTo8Xy3HwW04lg,1614
199
199
  keras/src/backend/openvino/math.py,sha256=qw9kX2sJ2qr0dBJF12Ey0E2GcwixPUqoev6UcNra4NI,3944
200
200
  keras/src/backend/openvino/nn.py,sha256=zULPxdwVO7JDZUUtsuoEEPCLQ09ew8z8T6G_i_NEqrM,23741
201
- keras/src/backend/openvino/numpy.py,sha256=wEaJROQYYiz8Yw2EWt_X_BeWJrgPMrlR-LlKMIrZE8U,113136
201
+ keras/src/backend/openvino/numpy.py,sha256=9wznF_6eqxuUd5CM4-Vnqufep-gdQUw9Y0ayYYGTMv4,113392
202
202
  keras/src/backend/openvino/random.py,sha256=4hRUtIP6qJxO3Qy9uH1x6jSuJna3nWPdUf4x2QU8-ew,5575
203
203
  keras/src/backend/openvino/rnn.py,sha256=ErmuZLPSgG9qU-NfYPPvBZ6Ysy8k-fA4g19Vhqq7OVQ,866
204
204
  keras/src/backend/openvino/trainer.py,sha256=bMmtSALqydqdS6ke-5sYW5fgxZDshDH810p_C0xCRTg,9087
@@ -211,7 +211,7 @@ keras/src/backend/tensorflow/layer.py,sha256=69d40LwL4HhKRsCjj1VRpjfrQXXF8VV3vh0
211
211
  keras/src/backend/tensorflow/linalg.py,sha256=_lZVfdY1tFvrN7xwbt3INGoTR0yC5v-kI1Q0XppVibY,8773
212
212
  keras/src/backend/tensorflow/math.py,sha256=zTu_7Ff6B2Ro862z_xH0OCmIWbV74DjsO5UnfjYuOUQ,12370
213
213
  keras/src/backend/tensorflow/nn.py,sha256=6vtZHzUED6_blUPE1Tnc3GAxPpJ2ebxoaiMn80tTL9k,51328
214
- keras/src/backend/tensorflow/numpy.py,sha256=8yiH61_ML4JRkZIYVysVnH3XdVaUVIWG1NG8dNrONWc,106883
214
+ keras/src/backend/tensorflow/numpy.py,sha256=Gp68IjpfHTnLj9QTxfBRODR7YQjWRez-Y8zo5n6_vGs,106811
215
215
  keras/src/backend/tensorflow/optimizer.py,sha256=kFlyEOnGjEYdLpd8mpwhUeku78__xBfZbbrDWpJrq60,9307
216
216
  keras/src/backend/tensorflow/random.py,sha256=iO8V_soaDXZm9ewyAVbjudhsMj08C348c9Bz64nxXC4,6475
217
217
  keras/src/backend/tensorflow/rnn.py,sha256=JbOSpt48cm612c7YwiTYOQCQsNXyI_6QeRhtUn8qEvM,34829
@@ -499,7 +499,7 @@ keras/src/ops/__init__.py,sha256=aORlvnrqY_eQl0EFLWdpHsXHnQ6JLSw1qhwJMr-VXJ0,644
499
499
  keras/src/ops/core.py,sha256=1L74Jox7wY6R_DFBzVVS3VjLlIKbE0sxyK5x-pjzx8Q,42779
500
500
  keras/src/ops/einops.py,sha256=-pxW0_AzDQNsR7t2TJrzvYXBJpmLYA3fJoO0U_U96PY,6268
501
501
  keras/src/ops/function.py,sha256=QV9n1-xeTPDK_FJ3sjlHDWVH2sqDj96R6YQnJueMOlA,17821
502
- keras/src/ops/image.py,sha256=Drfouun3Gaod0LNgG5nxrKkgIJ4STjWQWvzbTIjKOxs,67251
502
+ keras/src/ops/image.py,sha256=JtGvaPiqv04o8ZQJfOpZDXy8aXzPfn-MwnErfKcVHd4,67405
503
503
  keras/src/ops/linalg.py,sha256=3V8S_cgNxZZCIFcFj-FBHTdRqWNbimDtumMvfoc0f30,26736
504
504
  keras/src/ops/math.py,sha256=4qYMJ5qAPmeSyeF63YWoGbUkQt6f4_VX0enOChU4mXU,37233
505
505
  keras/src/ops/nn.py,sha256=04gjHB2BWusy4tWm59EO5Ns1paJC5umDNGwNCKzaJWQ,104658
@@ -550,8 +550,8 @@ keras/src/saving/orbax_util.py,sha256=ArJI9hQODUyyvzCiXt8AS3VH6E4SL0vF02-RHBk30g
550
550
  keras/src/saving/saving_api.py,sha256=X-zsTum57M3AWf_cYqhq_o5wgLcFxNh1ditoxbL_0LY,14694
551
551
  keras/src/saving/saving_lib.py,sha256=bRI8TeNOlflTfX3njSkkwNv-VYip-OW7ienIm0lL96I,58920
552
552
  keras/src/saving/serialization_lib.py,sha256=yzCTm8hin__MGA2N5M5F-8Zbts5ZJVmINbrH4wEtIwI,30334
553
- keras/src/testing/__init__.py,sha256=7vVsV7Rn3rG99DdURgnH8ncpxagRwIE0uhH-R4qDyok,315
554
- keras/src/testing/test_case.py,sha256=ZisRWfnbKiRdAee59wsq9PsDJGsAMGQKxMtELyERok0,31852
553
+ keras/src/testing/__init__.py,sha256=RQ5ZZ88NhcDTHCIpPulvaiTOTdJqAMH9ZhptXyMcqqY,368
554
+ keras/src/testing/test_case.py,sha256=24aSbz5WG5ICUavaLWo-PWBD_O9T7feRGvrLoNS19Q8,31780
555
555
  keras/src/testing/test_utils.py,sha256=6Vb8tJIyjU1ay63w3jvXNNhh7sSNrosQll4ii1NXELQ,6197
556
556
  keras/src/trainers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
557
557
  keras/src/trainers/compile_utils.py,sha256=k5FDn7we0RN9fhRslY_WOQZRFwfzjqpYmiDeOKkAKqk,31260
@@ -618,7 +618,7 @@ keras/utils/bounding_boxes/__init__.py,sha256=jtvQll4u8ZY0Z96HwNhP1nxWEG9FM3gI-6
618
618
  keras/utils/legacy/__init__.py,sha256=oSYZz6uS8UxSElRaaJYWJEoweJ4GAasZjnn7fNaOlog,342
619
619
  keras/visualization/__init__.py,sha256=UKWmiy6sps4SWlmQi9WX8_Z53cPpLlphz2zIeHdwJpQ,722
620
620
  keras/wrappers/__init__.py,sha256=QkS-O5K8qGS7C3sytF8MpmO6PasATpNVGF8qtb7Ojsw,407
621
- keras_nightly-3.14.0.dev2026013104.dist-info/METADATA,sha256=w0kkqL1AF73EhiimNKldJ4tSW7eCF5cKZwXLOhxviSM,6339
622
- keras_nightly-3.14.0.dev2026013104.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
623
- keras_nightly-3.14.0.dev2026013104.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
624
- keras_nightly-3.14.0.dev2026013104.dist-info/RECORD,,
621
+ keras_nightly-3.14.0.dev2026020104.dist-info/METADATA,sha256=T47ZKAAxW5fg84V14AxGHf_xKq5LpV3lmhdzMr5iE2I,6339
622
+ keras_nightly-3.14.0.dev2026020104.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
623
+ keras_nightly-3.14.0.dev2026020104.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
624
+ keras_nightly-3.14.0.dev2026020104.dist-info/RECORD,,