keras-nightly 3.14.0.dev2026012104__py3-none-any.whl → 3.14.0.dev2026012304__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.
Files changed (38) hide show
  1. keras/_tf_keras/keras/ops/__init__.py +1 -0
  2. keras/_tf_keras/keras/ops/numpy/__init__.py +1 -0
  3. keras/ops/__init__.py +1 -0
  4. keras/ops/numpy/__init__.py +1 -0
  5. keras/src/backend/jax/numpy.py +5 -0
  6. keras/src/backend/numpy/numpy.py +4 -0
  7. keras/src/backend/openvino/numpy.py +134 -6
  8. keras/src/backend/tensorflow/numpy.py +20 -0
  9. keras/src/backend/torch/numpy.py +18 -0
  10. keras/src/layers/layer.py +10 -1
  11. keras/src/layers/preprocessing/image_preprocessing/aug_mix.py +13 -0
  12. keras/src/layers/preprocessing/image_preprocessing/base_image_preprocessing_layer.py +58 -0
  13. keras/src/layers/preprocessing/image_preprocessing/cut_mix.py +13 -0
  14. keras/src/layers/preprocessing/image_preprocessing/max_num_bounding_box.py +23 -0
  15. keras/src/layers/preprocessing/image_preprocessing/rand_augment.py +15 -0
  16. keras/src/layers/preprocessing/image_preprocessing/random_color_degeneration.py +15 -0
  17. keras/src/layers/preprocessing/image_preprocessing/random_color_jitter.py +15 -0
  18. keras/src/layers/preprocessing/image_preprocessing/random_contrast.py +15 -0
  19. keras/src/layers/preprocessing/image_preprocessing/random_crop.py +15 -0
  20. keras/src/layers/preprocessing/image_preprocessing/random_elastic_transform.py +14 -0
  21. keras/src/layers/preprocessing/image_preprocessing/random_erasing.py +15 -0
  22. keras/src/layers/preprocessing/image_preprocessing/random_flip.py +15 -0
  23. keras/src/layers/preprocessing/image_preprocessing/random_gaussian_blur.py +15 -0
  24. keras/src/layers/preprocessing/image_preprocessing/random_grayscale.py +15 -0
  25. keras/src/layers/preprocessing/image_preprocessing/random_invert.py +15 -0
  26. keras/src/layers/preprocessing/image_preprocessing/random_perspective.py +14 -0
  27. keras/src/layers/preprocessing/image_preprocessing/random_posterization.py +15 -0
  28. keras/src/layers/preprocessing/image_preprocessing/random_rotation.py +15 -0
  29. keras/src/layers/preprocessing/image_preprocessing/random_sharpness.py +15 -0
  30. keras/src/layers/preprocessing/image_preprocessing/random_shear.py +15 -0
  31. keras/src/layers/preprocessing/image_preprocessing/random_translation.py +15 -0
  32. keras/src/ops/numpy.py +56 -0
  33. keras/src/regularizers/regularizers.py +2 -2
  34. keras/src/version.py +1 -1
  35. {keras_nightly-3.14.0.dev2026012104.dist-info → keras_nightly-3.14.0.dev2026012304.dist-info}/METADATA +1 -1
  36. {keras_nightly-3.14.0.dev2026012104.dist-info → keras_nightly-3.14.0.dev2026012304.dist-info}/RECORD +38 -38
  37. {keras_nightly-3.14.0.dev2026012104.dist-info → keras_nightly-3.14.0.dev2026012304.dist-info}/WHEEL +1 -1
  38. {keras_nightly-3.14.0.dev2026012104.dist-info → keras_nightly-3.14.0.dev2026012304.dist-info}/top_level.txt +0 -0
@@ -245,6 +245,7 @@ from keras.src.ops.numpy import mod as mod
245
245
  from keras.src.ops.numpy import moveaxis as moveaxis
246
246
  from keras.src.ops.numpy import multiply as multiply
247
247
  from keras.src.ops.numpy import nan_to_num as nan_to_num
248
+ from keras.src.ops.numpy import nanmin as nanmin
248
249
  from keras.src.ops.numpy import nansum as nansum
249
250
  from keras.src.ops.numpy import ndim as ndim
250
251
  from keras.src.ops.numpy import negative as negative
@@ -129,6 +129,7 @@ from keras.src.ops.numpy import mod as mod
129
129
  from keras.src.ops.numpy import moveaxis as moveaxis
130
130
  from keras.src.ops.numpy import multiply as multiply
131
131
  from keras.src.ops.numpy import nan_to_num as nan_to_num
132
+ from keras.src.ops.numpy import nanmin as nanmin
132
133
  from keras.src.ops.numpy import nansum as nansum
133
134
  from keras.src.ops.numpy import ndim as ndim
134
135
  from keras.src.ops.numpy import negative as negative
keras/ops/__init__.py CHANGED
@@ -245,6 +245,7 @@ from keras.src.ops.numpy import mod as mod
245
245
  from keras.src.ops.numpy import moveaxis as moveaxis
246
246
  from keras.src.ops.numpy import multiply as multiply
247
247
  from keras.src.ops.numpy import nan_to_num as nan_to_num
248
+ from keras.src.ops.numpy import nanmin as nanmin
248
249
  from keras.src.ops.numpy import nansum as nansum
249
250
  from keras.src.ops.numpy import ndim as ndim
250
251
  from keras.src.ops.numpy import negative as negative
@@ -129,6 +129,7 @@ from keras.src.ops.numpy import mod as mod
129
129
  from keras.src.ops.numpy import moveaxis as moveaxis
130
130
  from keras.src.ops.numpy import multiply as multiply
131
131
  from keras.src.ops.numpy import nan_to_num as nan_to_num
132
+ from keras.src.ops.numpy import nanmin as nanmin
132
133
  from keras.src.ops.numpy import nansum as nansum
133
134
  from keras.src.ops.numpy import ndim as ndim
134
135
  from keras.src.ops.numpy import negative as negative
@@ -1013,6 +1013,11 @@ def moveaxis(x, source, destination):
1013
1013
  return jnp.moveaxis(x, source=source, destination=destination)
1014
1014
 
1015
1015
 
1016
+ def nanmin(x, axis=None, keepdims=False):
1017
+ x = convert_to_tensor(x)
1018
+ return jnp.nanmin(x, axis=axis, keepdims=keepdims)
1019
+
1020
+
1016
1021
  def nansum(x, axis=None, keepdims=False):
1017
1022
  x = convert_to_tensor(x)
1018
1023
  return jnp.nansum(x, axis=axis, keepdims=keepdims)
@@ -960,6 +960,10 @@ def moveaxis(x, source, destination):
960
960
  return np.moveaxis(x, source=source, destination=destination)
961
961
 
962
962
 
963
+ def nanmin(x, axis=None, keepdims=False):
964
+ return np.nanmin(x, axis=axis, keepdims=keepdims)
965
+
966
+
963
967
  def nansum(x, axis=None, keepdims=False):
964
968
  axis = standardize_axis_for_numpy(axis)
965
969
  dtype = standardize_dtype(x.dtype)
@@ -1522,7 +1522,25 @@ def lcm(x1, x2):
1522
1522
 
1523
1523
 
1524
1524
  def ldexp(x1, x2):
1525
- raise NotImplementedError("`ldexp` is not supported with openvino backend")
1525
+ element_type = None
1526
+ if isinstance(x1, OpenVINOKerasTensor):
1527
+ element_type = x1.output.get_element_type()
1528
+ if isinstance(x2, OpenVINOKerasTensor):
1529
+ element_type = x2.output.get_element_type()
1530
+ x1 = get_ov_output(x1, element_type)
1531
+ x2 = get_ov_output(x2, element_type)
1532
+ x1, x2 = _align_operand_types(x1, x2, "ldexp()")
1533
+
1534
+ float_dtype = OPENVINO_DTYPES[config.floatx()]
1535
+ if x1.get_element_type().is_integral():
1536
+ x1 = ov_opset.convert(x1, float_dtype)
1537
+ if x2.get_element_type().is_integral():
1538
+ x2 = ov_opset.convert(x2, float_dtype)
1539
+
1540
+ const_two = ov_opset.constant(2, x2.get_element_type())
1541
+ result = ov_opset.multiply(x1, ov_opset.power(const_two, x2))
1542
+
1543
+ return OpenVINOKerasTensor(result.output(0))
1526
1544
 
1527
1545
 
1528
1546
  def less(x1, x2):
@@ -1779,9 +1797,42 @@ def logaddexp(x1, x2):
1779
1797
 
1780
1798
 
1781
1799
  def logaddexp2(x1, x2):
1782
- raise NotImplementedError(
1783
- "`logaddexp2` is not supported with openvino backend"
1800
+ element_type = None
1801
+ if isinstance(x1, OpenVINOKerasTensor):
1802
+ element_type = x1.output.get_element_type()
1803
+ if isinstance(x2, OpenVINOKerasTensor):
1804
+ element_type = x2.output.get_element_type()
1805
+ x1 = get_ov_output(x1, element_type)
1806
+ x2 = get_ov_output(x2, element_type)
1807
+ x1, x2 = _align_operand_types(x1, x2, "logaddexp2()")
1808
+
1809
+ if x1.element_type.is_integral() or x2.element_type.is_integral():
1810
+ float_dtype = OPENVINO_DTYPES[config.floatx()]
1811
+ if x1.get_element_type().is_integral():
1812
+ x1 = ov_opset.convert(x1, float_dtype)
1813
+ if x2.get_element_type().is_integral():
1814
+ x2 = ov_opset.convert(x2, float_dtype)
1815
+
1816
+ max_val = ov_opset.maximum(x1, x2)
1817
+
1818
+ sub = ov_opset.subtract(x1, x2)
1819
+ abs_diff = ov_opset.abs(sub)
1820
+
1821
+ neg_abs_diff = ov_opset.negative(abs_diff)
1822
+
1823
+ element_type = neg_abs_diff.get_element_type()
1824
+
1825
+ two = ov_opset.constant(2, dtype=element_type)
1826
+
1827
+ power_of_2 = ov_opset.power(two, neg_abs_diff)
1828
+
1829
+ one_plus_power = ov_opset.add(
1830
+ ov_opset.constant(1, dtype=element_type), power_of_2
1784
1831
  )
1832
+ log2_term = ov_opset.divide(ov_opset.log(one_plus_power), ov_opset.log(two))
1833
+ result = ov_opset.add(max_val, log2_term).output(0)
1834
+
1835
+ return OpenVINOKerasTensor(result)
1785
1836
 
1786
1837
 
1787
1838
  def logical_and(x1, x2):
@@ -2056,6 +2107,10 @@ def moveaxis(x, source, destination):
2056
2107
  return OpenVINOKerasTensor(ov_opset.transpose(x, axes_const).output(0))
2057
2108
 
2058
2109
 
2110
+ def nanmin(x, axis=None, keepdims=False):
2111
+ raise NotImplementedError("`nanmin` is not supported with openvino backend")
2112
+
2113
+
2059
2114
  def nansum(x, axis=None, keepdims=False):
2060
2115
  raise NotImplementedError("`nansum` is not supported with openvino backend")
2061
2116
 
@@ -3155,7 +3210,20 @@ def correlate(x1, x2, mode="valid"):
3155
3210
 
3156
3211
 
3157
3212
  def select(condlist, choicelist, default=0):
3158
- raise NotImplementedError("`select` is not supported with openvino backend")
3213
+ if len(condlist) != len(choicelist):
3214
+ raise ValueError(
3215
+ "select(): condlist and choicelist must have the same length"
3216
+ )
3217
+ conds = [get_ov_output(c) for c in condlist]
3218
+ choices = [get_ov_output(v) for v in choicelist]
3219
+
3220
+ result = get_ov_output(default)
3221
+ for cond_idx in reversed(range(len(conds))):
3222
+ cond = conds[cond_idx]
3223
+ choice = choices[cond_idx]
3224
+ choice, result = _align_operand_types(choice, result, "select()")
3225
+ result = ov_opset.select(cond, choice, result).output(0)
3226
+ return OpenVINOKerasTensor(result)
3159
3227
 
3160
3228
 
3161
3229
  def slogdet(x):
@@ -3165,6 +3233,66 @@ def slogdet(x):
3165
3233
 
3166
3234
 
3167
3235
  def argpartition(x, kth, axis=-1):
3168
- raise NotImplementedError(
3169
- "`argpartition` is not supported with openvino backend"
3236
+ x = get_ov_output(x)
3237
+ x_shape = x.get_partial_shape()
3238
+ rank = x_shape.rank.get_length()
3239
+ axis = canonicalize_axis(axis, rank)
3240
+ axes = list(range(rank))
3241
+ axes[axis], axes[-1] = axes[-1], axes[axis]
3242
+ x = ov_opset.transpose(x, ov_opset.constant(axes))
3243
+ x_shape_tensor = ov_opset.shape_of(x)
3244
+ n = ov_opset.gather(
3245
+ x_shape_tensor,
3246
+ ov_opset.constant(-1),
3247
+ ov_opset.constant(0),
3170
3248
  )
3249
+ if isinstance(kth, int) and kth < 0:
3250
+ kth_tensor = ov_opset.add(
3251
+ n,
3252
+ ov_opset.constant(kth, n.get_element_type()),
3253
+ )
3254
+ else:
3255
+ kth_tensor = ov_opset.constant(kth, n.get_element_type())
3256
+ one = ov_opset.constant(1, kth_tensor.get_element_type())
3257
+ k_val = ov_opset.add(kth_tensor, one)
3258
+ bottom_ind = ov_opset.topk(
3259
+ ov_opset.negative(x),
3260
+ k=k_val,
3261
+ axis=-1,
3262
+ mode="max",
3263
+ sort="value",
3264
+ ).output(1)
3265
+ one_hot_mask = ov_opset.one_hot(
3266
+ bottom_ind,
3267
+ n,
3268
+ ov_opset.constant(1),
3269
+ ov_opset.constant(0),
3270
+ axis=-1,
3271
+ )
3272
+ mask = ov_opset.reduce_sum(
3273
+ one_hot_mask,
3274
+ ov_opset.constant([-2]),
3275
+ keep_dims=False,
3276
+ )
3277
+ ones = ov_opset.broadcast(
3278
+ ov_opset.constant(1),
3279
+ x_shape_tensor,
3280
+ )
3281
+ proxy = ov_opset.subtract(ones, mask)
3282
+ remaining_k = ov_opset.subtract(n, k_val)
3283
+ top_ind = ov_opset.topk(
3284
+ proxy,
3285
+ k=remaining_k,
3286
+ axis=-1,
3287
+ mode="max",
3288
+ sort="value",
3289
+ ).output(1)
3290
+ result = ov_opset.concat([bottom_ind, top_ind], axis=-1)
3291
+ inv_axes = [0] * rank
3292
+ for i, a in enumerate(axes):
3293
+ inv_axes[a] = i
3294
+ result = ov_opset.transpose(
3295
+ result,
3296
+ ov_opset.constant(inv_axes),
3297
+ ).output(0)
3298
+ return OpenVINOKerasTensor(result)
@@ -2125,6 +2125,26 @@ def moveaxis(x, source, destination):
2125
2125
  return tf.transpose(x, perm)
2126
2126
 
2127
2127
 
2128
+ def nanmin(x, axis=None, keepdims=False):
2129
+ x = convert_to_tensor(x)
2130
+
2131
+ if not x.dtype.is_floating:
2132
+ dtype = standardize_dtype(x.dtype)
2133
+ if dtype == "bool":
2134
+ return tf.reduce_all(x, axis=axis, keepdims=keepdims)
2135
+ return tf.reduce_min(x, axis=axis, keepdims=keepdims)
2136
+
2137
+ x_clean = tf.where(
2138
+ tf.math.is_nan(x), tf.constant(float("inf"), dtype=x.dtype), x
2139
+ )
2140
+
2141
+ return tf.where(
2142
+ tf.reduce_all(tf.math.is_nan(x), axis=axis, keepdims=keepdims),
2143
+ tf.constant(float("nan"), dtype=x.dtype),
2144
+ tf.reduce_min(x_clean, axis=axis, keepdims=keepdims),
2145
+ )
2146
+
2147
+
2128
2148
  def nansum(x, axis=None, keepdims=False):
2129
2149
  x = convert_to_tensor(x)
2130
2150
  dtype = standardize_dtype(x.dtype)
@@ -1272,6 +1272,24 @@ def moveaxis(x, source, destination):
1272
1272
  return torch.moveaxis(x, source=source, destination=destination)
1273
1273
 
1274
1274
 
1275
+ def nanmin(x, axis=None, keepdims=False):
1276
+ x = convert_to_tensor(x)
1277
+ if not torch.is_floating_point(x):
1278
+ return torch.amin(x, dim=axis, keepdim=keepdims)
1279
+
1280
+ if axis == () or axis == []:
1281
+ return x
1282
+
1283
+ x_clean = torch.where(torch.isnan(x), float("inf"), x)
1284
+ out = torch.amin(x_clean, dim=axis, keepdim=keepdims)
1285
+
1286
+ return torch.where(
1287
+ torch.isnan(x).all(dim=axis, keepdim=keepdims),
1288
+ torch.tensor(float("nan"), dtype=x.dtype, device=get_device()),
1289
+ out,
1290
+ )
1291
+
1292
+
1275
1293
  def nansum(x, axis=None, keepdims=False):
1276
1294
  if isinstance(x, (list, tuple)):
1277
1295
  x = stack(x)
keras/src/layers/layer.py CHANGED
@@ -27,6 +27,7 @@ from keras.src import backend
27
27
  from keras.src import constraints
28
28
  from keras.src import dtype_policies
29
29
  from keras.src import initializers
30
+ from keras.src import ops
30
31
  from keras.src import regularizers
31
32
  from keras.src import tree
32
33
  from keras.src import utils
@@ -974,7 +975,15 @@ class Layer(BackendLayer, Operation):
974
975
  if self.activity_regularizer is not None:
975
976
  for output in tree.flatten(outputs):
976
977
  if backend.is_tensor(output):
977
- self.add_loss(self.activity_regularizer(output))
978
+ loss = self.activity_regularizer(output)
979
+ if output.ndim > 0:
980
+ # Normalize by batch size to ensure consistent
981
+ # regularization strength across batch sizes
982
+ batch_size = ops.cast(
983
+ ops.shape(output)[0], dtype=loss.dtype
984
+ )
985
+ loss = ops.divide_no_nan(loss, batch_size)
986
+ self.add_loss(loss)
978
987
 
979
988
  # Set `previous_mask` on outputs if available. It is provided only
980
989
  # for the first positional input arg and its mask.
@@ -5,6 +5,9 @@ from keras.src.api_export import keras_export
5
5
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
6
6
  BaseImagePreprocessingLayer,
7
7
  )
8
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
9
+ base_image_preprocessing_transform_example,
10
+ )
8
11
  from keras.src.random import SeedGenerator
9
12
  from keras.src.utils import backend_utils
10
13
 
@@ -71,6 +74,10 @@ class AugMix(BaseImagePreprocessingLayer):
71
74
  interpolation: The interpolation method to use for resizing operations.
72
75
  Options include `"nearest"`, `"bilinear"`. Default is `"bilinear"`.
73
76
  seed: Integer. Used to create a random seed.
77
+
78
+ Example:
79
+
80
+ {{base_image_preprocessing_transform_example}}
74
81
  """
75
82
 
76
83
  _USE_BASE_FACTOR = False
@@ -326,3 +333,9 @@ class AugMix(BaseImagePreprocessingLayer):
326
333
  }
327
334
  base_config = super().get_config()
328
335
  return {**base_config, **config}
336
+
337
+
338
+ AugMix.__doc__ = AugMix.__doc__.replace(
339
+ "{{base_image_preprocessing_transform_example}}",
340
+ base_image_preprocessing_transform_example.replace("{LayerName}", "AugMix"),
341
+ )
@@ -383,3 +383,61 @@ class BaseImagePreprocessingLayer(DataLayer):
383
383
  )
384
384
 
385
385
  return affine_matrix
386
+
387
+
388
+ base_image_preprocessing_transform_example = """
389
+ ```python
390
+ layer = keras.layers.{LayerName}(bounding_box_format="xyxy")
391
+ images = np.random.randint(0, 255, (4, 224, 224, 3), dtype="uint8")
392
+
393
+ bounding_boxes = {
394
+ "boxes": np.array([
395
+ [[10, 20, 100, 150], [50, 60, 200, 250]],
396
+ [[15, 25, 110, 160], [55, 65, 210, 260]],
397
+ [[20, 30, 120, 170], [60, 70, 220, 270]],
398
+ [[25, 35, 130, 180], [65, 75, 230, 280]],
399
+ ], dtype="float32"),
400
+ "labels": np.array([[0, 1], [1, 2], [2, 3], [0, 3]], dtype="int32")
401
+ }
402
+
403
+ labels = keras.ops.one_hot(
404
+ np.array([0, 1, 2, 3]),
405
+ num_classes=4
406
+ )
407
+
408
+ segmentation_masks = np.random.randint(0, 3, (4, 224, 224, 1), dtype="uint8")
409
+
410
+ output = layer(
411
+ {
412
+ "images": images,
413
+ "bounding_boxes": bounding_boxes,
414
+ "labels": labels,
415
+ "segmentation_masks": segmentation_masks
416
+ },
417
+ training=True
418
+ )
419
+ ```
420
+ """
421
+
422
+ base_image_preprocessing_color_example = """
423
+ ```python
424
+ layer = keras.layers.{LayerName}(value_range=(0, 255))
425
+ images = np.random.randint(0, 255, (8, 224, 224, 3), dtype="uint8")
426
+
427
+ labels = keras.ops.one_hot(
428
+ np.array([0, 1, 2, 0, 1, 2, 0, 1]),
429
+ num_classes=3
430
+ )
431
+
432
+ segmentation_masks = np.random.randint(0, 3, (8, 224, 224, 1), dtype="uint8")
433
+
434
+ output = layer(
435
+ {
436
+ "images": images,
437
+ "labels": labels,
438
+ "segmentation_masks": segmentation_masks
439
+ },
440
+ training=True
441
+ )
442
+ ```
443
+ """
@@ -2,6 +2,9 @@ from keras.src.api_export import keras_export
2
2
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
3
3
  BaseImagePreprocessingLayer,
4
4
  )
5
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
6
+ base_image_preprocessing_color_example,
7
+ )
5
8
  from keras.src.random import SeedGenerator
6
9
 
7
10
 
@@ -29,6 +32,10 @@ class CutMix(BaseImagePreprocessingLayer):
29
32
  in patch sizes, leading to more diverse and larger mixed patches.
30
33
  Defaults to 1.
31
34
  seed: Integer. Used to create a random seed.
35
+
36
+ Example:
37
+
38
+ {{base_image_preprocessing_color_example}}
32
39
  """
33
40
 
34
41
  _USE_BASE_FACTOR = False
@@ -227,3 +234,9 @@ class CutMix(BaseImagePreprocessingLayer):
227
234
  }
228
235
  base_config = super().get_config()
229
236
  return {**base_config, **config}
237
+
238
+
239
+ CutMix.__doc__ = CutMix.__doc__.replace(
240
+ "{{base_image_preprocessing_color_example}}",
241
+ base_image_preprocessing_color_example.replace("{LayerName}", "CutMix"),
242
+ )
@@ -15,6 +15,29 @@ class MaxNumBoundingBoxes(BaseImagePreprocessingLayer):
15
15
  max_number: Desired output number of bounding boxes.
16
16
  padding_value: The padding value of the `boxes` and `labels` in
17
17
  `bounding_boxes`. Defaults to `-1`.
18
+
19
+ Example:
20
+
21
+ ```python
22
+ max_boxes_layer = keras.layers.MaxNumBoundingBoxes(
23
+ max_number=10,
24
+ fill_value=-1
25
+ )
26
+
27
+ images = np.random.randint(0, 255, (1, 224, 224, 3), dtype="uint8")
28
+
29
+ bounding_boxes = {
30
+ "boxes": np.array([
31
+ [[10, 20, 100, 150], [50, 60, 200, 250], [0, 0, 50, 50]],
32
+ ]),
33
+ "labels": np.array([[1, 2, 3]])
34
+ }
35
+
36
+ result = max_boxes_layer({
37
+ "images": images,
38
+ "bounding_boxes": bounding_boxes
39
+ })
40
+ ```
18
41
  """
19
42
 
20
43
  def __init__(self, max_number, fill_value=-1, **kwargs):
@@ -3,6 +3,9 @@ from keras.src.api_export import keras_export
3
3
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
4
4
  BaseImagePreprocessingLayer,
5
5
  )
6
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
7
+ base_image_preprocessing_transform_example,
8
+ )
6
9
  from keras.src.random import SeedGenerator
7
10
  from keras.src.utils import backend_utils
8
11
 
@@ -32,6 +35,10 @@ class RandAugment(BaseImagePreprocessingLayer):
32
35
  interpolation: The interpolation method to use for resizing operations.
33
36
  Options include `nearest`, `bilinear`. Default is `bilinear`.
34
37
  seed: Integer. Used to create a random seed.
38
+
39
+ Example:
40
+
41
+ {{base_image_preprocessing_transform_example}}
35
42
  """
36
43
 
37
44
  _USE_BASE_FACTOR = False
@@ -265,3 +272,11 @@ class RandAugment(BaseImagePreprocessingLayer):
265
272
  }
266
273
  base_config = super().get_config()
267
274
  return {**base_config, **config}
275
+
276
+
277
+ RandAugment.__doc__ = RandAugment.__doc__.replace(
278
+ "{{base_image_preprocessing_transform_example}}",
279
+ base_image_preprocessing_transform_example.replace(
280
+ "{LayerName}", "RandAugment"
281
+ ),
282
+ )
@@ -2,6 +2,9 @@ from keras.src.api_export import keras_export
2
2
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
3
3
  BaseImagePreprocessingLayer,
4
4
  )
5
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
6
+ base_image_preprocessing_color_example,
7
+ )
5
8
  from keras.src.random import SeedGenerator
6
9
 
7
10
 
@@ -29,6 +32,10 @@ class RandomColorDegeneration(BaseImagePreprocessingLayer):
29
32
  passed float is sampled. In order to ensure the value is always the
30
33
  same, please pass a tuple with two identical floats: `(0.5, 0.5)`.
31
34
  seed: Integer. Used to create a random seed.
35
+
36
+ Example:
37
+
38
+ {{base_image_preprocessing_color_example}}
32
39
  """
33
40
 
34
41
  _VALUE_RANGE_VALIDATION_ERROR = (
@@ -133,3 +140,11 @@ class RandomColorDegeneration(BaseImagePreprocessingLayer):
133
140
 
134
141
  def compute_output_shape(self, input_shape):
135
142
  return input_shape
143
+
144
+
145
+ RandomColorDegeneration.__doc__ = RandomColorDegeneration.__doc__.replace(
146
+ "{{base_image_preprocessing_color_example}}",
147
+ base_image_preprocessing_color_example.replace(
148
+ "{LayerName}", "RandomColorDegeneration"
149
+ ),
150
+ )
@@ -6,6 +6,9 @@ from keras.src.api_export import keras_export
6
6
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
7
7
  BaseImagePreprocessingLayer,
8
8
  )
9
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
10
+ base_image_preprocessing_color_example,
11
+ )
9
12
  from keras.src.random.seed_generator import SeedGenerator
10
13
  from keras.src.utils import backend_utils
11
14
 
@@ -60,6 +63,10 @@ class RandomColorJitter(BaseImagePreprocessingLayer):
60
63
  always the same, please pass a tuple with two identical
61
64
  floats: `(0.5, 0.5)`.
62
65
  seed: Integer. Used to create a random seed.
66
+
67
+ Example:
68
+
69
+ {{base_image_preprocessing_color_example}}
63
70
  """
64
71
 
65
72
  def __init__(
@@ -211,3 +218,11 @@ class RandomColorJitter(BaseImagePreprocessingLayer):
211
218
  }
212
219
  base_config = super().get_config()
213
220
  return {**base_config, **config}
221
+
222
+
223
+ RandomColorJitter.__doc__ = RandomColorJitter.__doc__.replace(
224
+ "{{base_image_preprocessing_color_example}}",
225
+ base_image_preprocessing_color_example.replace(
226
+ "{LayerName}", "RandomColorJitter"
227
+ ),
228
+ )
@@ -2,6 +2,9 @@ from keras.src.api_export import keras_export
2
2
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
3
3
  BaseImagePreprocessingLayer,
4
4
  )
5
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
6
+ base_image_preprocessing_color_example,
7
+ )
5
8
  from keras.src.random.seed_generator import SeedGenerator
6
9
 
7
10
 
@@ -45,6 +48,10 @@ class RandomContrast(BaseImagePreprocessingLayer):
45
48
  typically either `[0, 1]` or `[0, 255]` depending on how your
46
49
  preprocessing pipeline is set up.
47
50
  seed: Integer. Used to create a random seed.
51
+
52
+ Example:
53
+
54
+ {{base_image_preprocessing_color_example}}
48
55
  """
49
56
 
50
57
  _FACTOR_BOUNDS = (0, 1)
@@ -147,3 +154,11 @@ class RandomContrast(BaseImagePreprocessingLayer):
147
154
  }
148
155
  base_config = super().get_config()
149
156
  return {**base_config, **config}
157
+
158
+
159
+ RandomContrast.__doc__ = RandomContrast.__doc__.replace(
160
+ "{{base_image_preprocessing_color_example}}",
161
+ base_image_preprocessing_color_example.replace(
162
+ "{LayerName}", "RandomContrast"
163
+ ),
164
+ )
@@ -3,6 +3,9 @@ from keras.src.api_export import keras_export
3
3
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
4
4
  BaseImagePreprocessingLayer,
5
5
  )
6
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
7
+ base_image_preprocessing_transform_example,
8
+ )
6
9
  from keras.src.layers.preprocessing.image_preprocessing.bounding_boxes.converters import ( # noqa: E501
7
10
  convert_format,
8
11
  )
@@ -47,6 +50,10 @@ class RandomCrop(BaseImagePreprocessingLayer):
47
50
  seed: Integer. Used to create a random seed.
48
51
  **kwargs: Base layer keyword arguments, such as
49
52
  `name` and `dtype`.
53
+
54
+ Example:
55
+
56
+ {{base_image_preprocessing_transform_example}}
50
57
  """
51
58
 
52
59
  def __init__(
@@ -274,3 +281,11 @@ class RandomCrop(BaseImagePreprocessingLayer):
274
281
  }
275
282
  )
276
283
  return config
284
+
285
+
286
+ RandomCrop.__doc__ = RandomCrop.__doc__.replace(
287
+ "{{base_image_preprocessing_transform_example}}",
288
+ base_image_preprocessing_transform_example.replace(
289
+ "{LayerName}", "RandomCrop"
290
+ ),
291
+ )
@@ -2,6 +2,9 @@ from keras.src.api_export import keras_export
2
2
  from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
3
3
  BaseImagePreprocessingLayer,
4
4
  )
5
+ from keras.src.layers.preprocessing.image_preprocessing.base_image_preprocessing_layer import ( # noqa: E501
6
+ base_image_preprocessing_transform_example,
7
+ )
5
8
  from keras.src.random.seed_generator import SeedGenerator
6
9
 
7
10
 
@@ -62,6 +65,9 @@ class RandomElasticTransform(BaseImagePreprocessingLayer):
62
65
  preprocessing pipeline is set up.
63
66
  seed: Integer. Used to create a random seed.
64
67
 
68
+ Example:
69
+
70
+ {{base_image_preprocessing_transform_example}}
65
71
  """
66
72
 
67
73
  _USE_BASE_FACTOR = False
@@ -277,3 +283,11 @@ class RandomElasticTransform(BaseImagePreprocessingLayer):
277
283
  "seed": self.seed,
278
284
  }
279
285
  return {**base_config, **config}
286
+
287
+
288
+ RandomElasticTransform.__doc__ = RandomElasticTransform.__doc__.replace(
289
+ "{{base_image_preprocessing_transform_example}}",
290
+ base_image_preprocessing_transform_example.replace(
291
+ "{LayerName}", "RandomElasticTransform"
292
+ ),
293
+ )