keras-nightly 3.12.0.dev2025090103__py3-none-any.whl → 3.12.0.dev2025090203__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.
@@ -7,7 +7,7 @@ def _classes_shape(batched, classes_shape, max_boxes):
7
7
  return None
8
8
  if batched:
9
9
  return [None, max_boxes] + classes_shape[2:]
10
- return [max_boxes] + classes_shape[2:]
10
+ return [max_boxes] + classes_shape[1:]
11
11
 
12
12
 
13
13
  def _box_shape(batched, boxes_shape, max_boxes):
@@ -91,20 +91,20 @@ def densify_bounding_boxes(
91
91
  labels_default_value for _ in range(num_boxes_to_add)
92
92
  ]
93
93
  return {
94
- "boxes": backend.convert_to_tensor(new_boxes, dtype="int32"),
95
- "labels": backend.convert_to_tensor(new_boxes, dtype="int32"),
94
+ "boxes": backend.convert_to_tensor(new_boxes, dtype="float32"),
95
+ "labels": backend.convert_to_tensor(new_labels, dtype="int32"),
96
96
  }
97
97
 
98
98
  if tf_utils.is_ragged_tensor(boxes):
99
99
  bounding_boxes["boxes"] = bounding_boxes["boxes"].to_tensor(
100
100
  default_value=boxes_default_value,
101
- shape=_classes_shape(
101
+ shape=_box_shape(
102
102
  is_batched, bounding_boxes["boxes"].shape, max_boxes
103
103
  ),
104
104
  )
105
105
  bounding_boxes["labels"] = bounding_boxes["labels"].to_tensor(
106
106
  default_value=labels_default_value,
107
- shape=_box_shape(
107
+ shape=_classes_shape(
108
108
  is_batched, bounding_boxes["labels"].shape, max_boxes
109
109
  ),
110
110
  )
@@ -130,15 +130,55 @@ class Operation(KerasSaveable):
130
130
  vars(instance)["_object__state"] = nnx.object.ObjectState()
131
131
 
132
132
  # Generate a config to be returned by default by `get_config()`.
133
- arg_names = inspect.getfullargspec(cls.__init__).args
134
- kwargs.update(dict(zip(arg_names[1 : len(args) + 1], args)))
133
+ auto_config = True
134
+
135
+ signature = inspect.signature(cls.__init__)
136
+ argspec = inspect.getfullargspec(cls.__init__)
137
+
138
+ try:
139
+ bound_parameters = signature.bind(None, *args, **kwargs)
140
+ except TypeError:
141
+ # Raised by signature.bind when the supplied args and kwargs
142
+ # do not match the signature.
143
+ auto_config = False
144
+
145
+ if auto_config and any(
146
+ [
147
+ param.kind == inspect.Parameter.POSITIONAL_ONLY
148
+ for name, param in signature.parameters.items()
149
+ if name != argspec.args[0]
150
+ ]
151
+ ):
152
+ # cls.__init__ takes positional only arguments, which
153
+ # cannot be restored via cls(**config)
154
+ auto_config = False
155
+ # Create variable to show appropriate warning in get_config.
156
+ instance._auto_config_error_args = True
157
+
158
+ if auto_config:
159
+ # Include default values in the config.
160
+ bound_parameters.apply_defaults()
161
+ # Extract all arguments as a dictionary.
162
+ kwargs = bound_parameters.arguments
163
+ # Expand variable kwargs argument.
164
+ kwargs |= kwargs.pop(argspec.varkw, {})
165
+ # Remove first positional argument, self.
166
+ kwargs.pop(argspec.args[0])
167
+ # Remove argument "name", as it is provided by get_config.
168
+ kwargs.pop("name", None)
169
+ if argspec.varargs is not None:
170
+ # Varargs cannot be meaningfully converted to a dictionary.
171
+ varargs = kwargs.pop(argspec.varargs)
172
+ if len(varargs) > 0:
173
+ auto_config = False
174
+ # Store variable to show appropriate warning in get_config.
175
+ instance._auto_config_error_args = True
135
176
 
136
177
  # For safety, we only rely on auto-configs for a small set of
137
178
  # serializable types.
138
179
  supported_types = (str, int, float, bool, type(None))
139
180
  try:
140
181
  flat_arg_values = tree.flatten(kwargs)
141
- auto_config = True
142
182
  for value in flat_arg_values:
143
183
  if not isinstance(value, supported_types):
144
184
  auto_config = False
@@ -193,30 +233,52 @@ class Operation(KerasSaveable):
193
233
  config.pop("name", None)
194
234
  return config
195
235
  else:
196
- raise NotImplementedError(
197
- textwrap.dedent(
198
- f"""
199
- Object {self.__class__.__name__} was created by passing
200
- non-serializable argument values in `__init__()`,
201
- and therefore the object must override `get_config()` in
202
- order to be serializable. Please implement `get_config()`.
203
-
204
- Example:
205
-
206
- class CustomLayer(keras.layers.Layer):
207
- def __init__(self, arg1, arg2, **kwargs):
208
- super().__init__(**kwargs)
209
- self.arg1 = arg1
210
- self.arg2 = arg2
211
-
212
- def get_config(self):
213
- config = super().get_config()
214
- config.update({"arg1": self.arg1,
215
- "arg2": self.arg2,
216
- })
217
- return config"""
236
+ example_str = """
237
+ class CustomLayer(keras.layers.Layer):
238
+ def __init__(self, arg1, arg2, **kwargs):
239
+ super().__init__(**kwargs)
240
+ self.arg1 = arg1
241
+ self.arg2 = arg2
242
+
243
+ def get_config(self):
244
+ config = super().get_config()
245
+ config.update({
246
+ "arg1": self.arg1,
247
+ "arg2": self.arg2,
248
+ })
249
+ return config
250
+ """
251
+ if getattr(self, "_auto_config_error_args", False):
252
+ raise NotImplementedError(
253
+ textwrap.dedent(
254
+ f"""
255
+ Object {self.__class__.__name__} was created by passing
256
+ positional only or variadic positional arguments (e.g.,
257
+ `*args`) to `__init__()`, which is not supported by the
258
+ automatic config generation. Please remove all positional
259
+ only and variadic arguments from `__init__()`
260
+ or override `get_config()` and `from_config()` to make
261
+ the object serializatble.
262
+
263
+ Example:
264
+
265
+ {example_str}"""
266
+ )
267
+ )
268
+ else:
269
+ raise NotImplementedError(
270
+ textwrap.dedent(
271
+ f"""
272
+ Object {self.__class__.__name__} was created by passing
273
+ non-serializable argument values in `__init__()`,
274
+ and therefore the object must override `get_config()` in
275
+ order to be serializable. Please implement `get_config()`.
276
+
277
+ Example:
278
+
279
+ {example_str}"""
280
+ )
218
281
  )
219
- )
220
282
 
221
283
  @classmethod
222
284
  def from_config(cls, config):
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.12.0.dev2025090103"
4
+ __version__ = "3.12.0.dev2025090203"
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.12.0.dev2025090103
3
+ Version: 3.12.0.dev2025090203
4
4
  Summary: Multi-backend Keras
5
5
  Author-email: Keras team <keras-users@googlegroups.com>
6
6
  License: Apache License 2.0
@@ -126,7 +126,7 @@ keras/regularizers/__init__.py,sha256=542Shphw7W8h4Dyf2rmqMKUECVZ8IVBvN9g1LWhz-b
126
126
  keras/saving/__init__.py,sha256=KvL2GZxjvgFgEhvEnkvqjIR9JSNHKz-NWZacXajsjLI,1298
127
127
  keras/src/__init__.py,sha256=Gi4S7EiCMkE03PbdGNpFdaUYySWDs_FcAJ8Taz9Y1BE,684
128
128
  keras/src/api_export.py,sha256=gXOkBOnmscV013WAc75lc4Up01-Kkg9EylIAT_QWctg,1173
129
- keras/src/version.py,sha256=wR6UDH2ffMhDy3CqP7QIiRJaoJxgLXXi65Oe-E2PWE4,204
129
+ keras/src/version.py,sha256=Cin1ggWTmgri7XO7xLkow07ZNGSjmu8f-dDtkf5xHvk,204
130
130
  keras/src/activations/__init__.py,sha256=0nL3IFDB9unlrMz8ninKOWo-uCHasTUpTo1tXZb2u44,4433
131
131
  keras/src/activations/activations.py,sha256=mogPggtp4CGldI3VOPNmesRxp6EbiR1_i4KLGaVwzL8,17614
132
132
  keras/src/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -410,7 +410,7 @@ keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/bounding_box.p
410
410
  keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/converters.py,sha256=opXlmX5SRiWEU2_M1PqkiBVi8LRNfIIDMPMfMY_2Yp0,15999
411
411
  keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/formats.py,sha256=b4v7nskUauUvk7Ub4rgImPUysJrDl4m5oBTGD1MEnTI,3377
412
412
  keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/iou.py,sha256=ZwqkN4d2QoYlK6sIv2OJ7MkRyObLmdRMKflb1Tp0YJ4,10140
413
- keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/validation.py,sha256=aNeC8VBG2xY7qvNAcbTpb824SDyOf88iGMNIohwsjQk,7189
413
+ keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/validation.py,sha256=BIbkLBosoWWXAiqqgeDcg7w7NpP3K9ODXWrv1TYceFo,7192
414
414
  keras/src/layers/regularization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
415
415
  keras/src/layers/regularization/activity_regularization.py,sha256=FCUAcb3Pyotp2lmoks6Ixb6lmNfg-Pa4eGgW6C7S5zQ,1283
416
416
  keras/src/layers/regularization/alpha_dropout.py,sha256=z2Kl3Pblx4eZnJWUiAUgUogu4A1pTPclwzH_Sa-B4Fs,3625
@@ -490,7 +490,7 @@ keras/src/ops/math.py,sha256=4qYMJ5qAPmeSyeF63YWoGbUkQt6f4_VX0enOChU4mXU,37233
490
490
  keras/src/ops/nn.py,sha256=1BC-zmnpsUhqG5lSE4VvV5PsBf81wN0ZGg4kU-R8TJY,95259
491
491
  keras/src/ops/node.py,sha256=aJgn9D-GkteE--Bbt2cZ9JjVxb2W2uS1OWEKoeLsl3Y,5583
492
492
  keras/src/ops/numpy.py,sha256=ovWnm3XHDIzjiwjm_GjM0oVZHCGige7Ek95cX4qCAvk,236694
493
- keras/src/ops/operation.py,sha256=Q-nOnXPrmt2daaC3X1png3Y86sFPDttrNEopPb6o3wM,12957
493
+ keras/src/ops/operation.py,sha256=dpPI6bQsdBk6j0EUNygoLRHngrMTDoqT2Z55mgq6hbE,15520
494
494
  keras/src/ops/operation_utils.py,sha256=BSarr5DZF5dr-URdXNzawwZlFx6R7VRjh6P2DGwgrT4,14457
495
495
  keras/src/ops/symbolic_arguments.py,sha256=MKwXxZYkyouD9BPmQ1uUNxILdcwPvTayAqXaUV3P3o4,1628
496
496
  keras/src/optimizers/__init__.py,sha256=k7AmJUexCuGHTvU5gCrL_Pf7XYQmA6dZjJ47kcLvqfk,3974
@@ -597,7 +597,7 @@ keras/utils/bounding_boxes/__init__.py,sha256=jtvQll4u8ZY0Z96HwNhP1nxWEG9FM3gI-6
597
597
  keras/utils/legacy/__init__.py,sha256=oSYZz6uS8UxSElRaaJYWJEoweJ4GAasZjnn7fNaOlog,342
598
598
  keras/visualization/__init__.py,sha256=UKWmiy6sps4SWlmQi9WX8_Z53cPpLlphz2zIeHdwJpQ,722
599
599
  keras/wrappers/__init__.py,sha256=QkS-O5K8qGS7C3sytF8MpmO6PasATpNVGF8qtb7Ojsw,407
600
- keras_nightly-3.12.0.dev2025090103.dist-info/METADATA,sha256=8h4vgmfQG-ojifS5KcReo2WDWMppje7vYId2_3kTNY4,5970
601
- keras_nightly-3.12.0.dev2025090103.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
602
- keras_nightly-3.12.0.dev2025090103.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
603
- keras_nightly-3.12.0.dev2025090103.dist-info/RECORD,,
600
+ keras_nightly-3.12.0.dev2025090203.dist-info/METADATA,sha256=s7mkZeqWT6lGz1lr5t2Sr7W8mFmfVhuwliOIURlu1Eg,5970
601
+ keras_nightly-3.12.0.dev2025090203.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
602
+ keras_nightly-3.12.0.dev2025090203.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
603
+ keras_nightly-3.12.0.dev2025090203.dist-info/RECORD,,