tf-keras-nightly 2.19.0.dev2025012210__py3-none-any.whl → 2.19.0.dev2025012410__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.
- tf_keras/__init__.py +1 -1
- tf_keras/src/engine/base_layer.py +1 -1
- tf_keras/src/engine/sequential.py +29 -12
- {tf_keras_nightly-2.19.0.dev2025012210.dist-info → tf_keras_nightly-2.19.0.dev2025012410.dist-info}/METADATA +1 -1
- {tf_keras_nightly-2.19.0.dev2025012210.dist-info → tf_keras_nightly-2.19.0.dev2025012410.dist-info}/RECORD +7 -7
- {tf_keras_nightly-2.19.0.dev2025012210.dist-info → tf_keras_nightly-2.19.0.dev2025012410.dist-info}/WHEEL +0 -0
- {tf_keras_nightly-2.19.0.dev2025012210.dist-info → tf_keras_nightly-2.19.0.dev2025012410.dist-info}/top_level.txt +0 -0
tf_keras/__init__.py
CHANGED
@@ -2321,7 +2321,7 @@ class Layer(tf.Module, version_utils.LayerVersionSelector):
|
|
2321
2321
|
"""
|
2322
2322
|
input_shape = config["input_shape"]
|
2323
2323
|
if input_shape is not None:
|
2324
|
-
self.build(input_shape)
|
2324
|
+
self.build(tf_utils.convert_shapes(input_shape, to_tuples=False))
|
2325
2325
|
|
2326
2326
|
############################################################################
|
2327
2327
|
# Methods & attributes below are all private and only used by the framework.
|
@@ -285,12 +285,16 @@ class Sequential(functional.Functional):
|
|
285
285
|
):
|
286
286
|
# Determine whether the input shape is novel, i.e. whether the model
|
287
287
|
# should be rebuilt.
|
288
|
-
input_shape =
|
288
|
+
input_shape = tf_utils.convert_shapes(input_shape)
|
289
289
|
if self._inferred_input_shape is None:
|
290
290
|
new_shape = input_shape
|
291
291
|
else:
|
292
|
-
new_shape =
|
293
|
-
|
292
|
+
new_shape = tf.nest.map_structure(
|
293
|
+
_relax_input_shape,
|
294
|
+
tf_utils.convert_shapes(
|
295
|
+
self._inferred_input_shape, to_tuples=False
|
296
|
+
),
|
297
|
+
tf_utils.convert_shapes(input_shape, to_tuples=False),
|
294
298
|
)
|
295
299
|
if (
|
296
300
|
new_shape is not None
|
@@ -299,10 +303,13 @@ class Sequential(functional.Functional):
|
|
299
303
|
# A novel shape has been received: we need to rebuild the model.
|
300
304
|
# In case we are inside a graph function, we step out of it.
|
301
305
|
with tf.init_scope():
|
302
|
-
inputs =
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
+
inputs = tf.nest.map_structure(
|
307
|
+
lambda s: input_layer.Input(
|
308
|
+
batch_shape=tf_utils.convert_shapes(s),
|
309
|
+
dtype=input_dtype,
|
310
|
+
name=self.layers[0].name + "_input",
|
311
|
+
),
|
312
|
+
tf_utils.convert_shapes(new_shape, to_tuples=False),
|
306
313
|
)
|
307
314
|
layer_input = inputs
|
308
315
|
created_nodes = set()
|
@@ -370,7 +377,7 @@ class Sequential(functional.Functional):
|
|
370
377
|
raise ValueError("You must provide an `input_shape` argument.")
|
371
378
|
self._build_graph_network_for_inferred_shape(input_shape)
|
372
379
|
if not self.built:
|
373
|
-
input_shape =
|
380
|
+
input_shape = tf_utils.convert_shapes(input_shape)
|
374
381
|
self._build_input_shape = input_shape
|
375
382
|
super().build(input_shape)
|
376
383
|
self.built = True
|
@@ -435,7 +442,8 @@ class Sequential(functional.Functional):
|
|
435
442
|
def get_config(self):
|
436
443
|
layer_configs = []
|
437
444
|
serialize_obj_fn = serialization_lib.serialize_keras_object
|
438
|
-
|
445
|
+
use_legacy_config = getattr(self, "use_legacy_config", False)
|
446
|
+
if use_legacy_config:
|
439
447
|
serialize_obj_fn = legacy_serialization.serialize_keras_object
|
440
448
|
for layer in super().layers:
|
441
449
|
# `super().layers` include the InputLayer if available (it is
|
@@ -446,7 +454,11 @@ class Sequential(functional.Functional):
|
|
446
454
|
config = training.Model.get_config(self)
|
447
455
|
config["name"] = self.name
|
448
456
|
config["layers"] = copy.deepcopy(layer_configs)
|
449
|
-
if
|
457
|
+
if (
|
458
|
+
use_legacy_config
|
459
|
+
and not self._is_graph_network
|
460
|
+
and self._build_input_shape
|
461
|
+
):
|
450
462
|
config["build_input_shape"] = self._build_input_shape
|
451
463
|
return config
|
452
464
|
|
@@ -458,6 +470,7 @@ class Sequential(functional.Functional):
|
|
458
470
|
layer_configs = config["layers"]
|
459
471
|
else:
|
460
472
|
name = None
|
473
|
+
build_input_shape = None
|
461
474
|
layer_configs = config
|
462
475
|
model = cls(name=name)
|
463
476
|
for layer_config in layer_configs:
|
@@ -519,11 +532,15 @@ def _get_shape_tuple(t):
|
|
519
532
|
return None
|
520
533
|
|
521
534
|
|
522
|
-
def
|
535
|
+
def _relax_input_shape(shape_1, shape_2):
|
523
536
|
if shape_1 is None or shape_2 is None:
|
524
537
|
return None
|
525
|
-
if
|
538
|
+
if shape_1.rank is None or shape_2.rank is None:
|
539
|
+
return None
|
540
|
+
if shape_1.rank != shape_2.rank:
|
526
541
|
return None
|
542
|
+
shape_1 = shape_1.as_list()
|
543
|
+
shape_2 = shape_2.as_list()
|
527
544
|
return tuple(None if d1 != d2 else d1 for d1, d2 in zip(shape_1, shape_2))
|
528
545
|
|
529
546
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
tf_keras/__init__.py,sha256=
|
1
|
+
tf_keras/__init__.py,sha256=fsB85OKKdOM_b2buioLft_O7KkFFpeC15zKCw1M9SHY,911
|
2
2
|
tf_keras/__internal__/__init__.py,sha256=OHQbeIC0QtRBI7dgXaJaVbH8F00x8dCI-DvEcIfyMsE,671
|
3
3
|
tf_keras/__internal__/backend/__init__.py,sha256=LnMs2A6685gDG79fxqmdulIYlVE_3WmXlBTBo9ZWYcw,162
|
4
4
|
tf_keras/__internal__/layers/__init__.py,sha256=F5SGMhOTPzm-PR44VrfinURHcVeQPIEdwnZlAkSTB3A,176
|
@@ -271,7 +271,7 @@ tf_keras/src/dtensor/lazy_variable.py,sha256=c3yylbga0se3Geflutss3fz5RzBYuY2vkU3
|
|
271
271
|
tf_keras/src/dtensor/test_util.py,sha256=9QAbt44mlirdqwG2ertTsoXNKG2V4Z0bqJFxGdxy5BY,4572
|
272
272
|
tf_keras/src/dtensor/utils.py,sha256=2TTSCEOA61Ia1FAPfQWJ2CRfiocBGUZreXH9UBFzFbk,6441
|
273
273
|
tf_keras/src/engine/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
274
|
-
tf_keras/src/engine/base_layer.py,sha256=
|
274
|
+
tf_keras/src/engine/base_layer.py,sha256=H7TK3ezXORn1B79TZO3klFGE_hmXHAauS3h5k_8xJvA,156553
|
275
275
|
tf_keras/src/engine/base_layer_utils.py,sha256=YMJF5sZJhFF_yzfqOtqi4YTsyUE2ZQ_cJJOIdXnuS2w,35795
|
276
276
|
tf_keras/src/engine/base_layer_v1.py,sha256=cX-OCSNio3Tr2M6twr_PUgKulePLZDNW_4xLXjgYbN4,102700
|
277
277
|
tf_keras/src/engine/base_preprocessing_layer.py,sha256=xne5VVtj9_IE1_cjh-kaPk-utoMY7mYwTOcgybFfY34,12650
|
@@ -285,7 +285,7 @@ tf_keras/src/engine/keras_tensor.py,sha256=rmIyf-sMKzGAMXzob0hCTZ3qA4JBYyIM85XUd
|
|
285
285
|
tf_keras/src/engine/node.py,sha256=mevKNFEtzeVbwLRuwB7sMzQGKt6ppIxLmMcfQMzu8N8,14254
|
286
286
|
tf_keras/src/engine/partial_batch_padding_handler.py,sha256=TNZvGXL-fvmZLLHIMPX_hy0w9LT8W52DHW7ZtnEvBvI,4325
|
287
287
|
tf_keras/src/engine/saving.py,sha256=So_T5PRjCOLzpOPGHNBiTCOrNvqvvGNK8AwZBwFQCbs,853
|
288
|
-
tf_keras/src/engine/sequential.py,sha256=
|
288
|
+
tf_keras/src/engine/sequential.py,sha256=YZaO53uU2XWmAa4wMjZ6XLiO2O5lPnYZ4IEeDCQAxqA,23675
|
289
289
|
tf_keras/src/engine/training.py,sha256=eaEAV4OaV_0NmwIi_Upm-bZQKBzyCl_ilSFZ3Cinvqg,193232
|
290
290
|
tf_keras/src/engine/training_arrays_v1.py,sha256=Fn_PY4_7miHhmkhXoNJS42LEpQDZ0VWOyNGv5m2DKNE,30903
|
291
291
|
tf_keras/src/engine/training_distributed_v1.py,sha256=niN6TZ1DpXkWGUA7CWH6--VxFRLlX48RnqkGpHym4fE,32084
|
@@ -606,7 +606,7 @@ tf_keras/src/utils/legacy/__init__.py,sha256=EfMmeHYDzwvxNaktPhQbkTdcPSIGCqMhBND
|
|
606
606
|
tf_keras/utils/__init__.py,sha256=b7_d-USe_EmLo02_P99Q1rUCzKBYayPCfiYFStP-0nw,2735
|
607
607
|
tf_keras/utils/experimental/__init__.py,sha256=DzGogE2AosjxOVILQBT8PDDcqbWTc0wWnZRobCdpcec,97
|
608
608
|
tf_keras/utils/legacy/__init__.py,sha256=7ujlDa5HeSRcth2NdqA0S1P2-VZF1kB3n68jye6Dj-8,189
|
609
|
-
tf_keras_nightly-2.19.0.
|
610
|
-
tf_keras_nightly-2.19.0.
|
611
|
-
tf_keras_nightly-2.19.0.
|
612
|
-
tf_keras_nightly-2.19.0.
|
609
|
+
tf_keras_nightly-2.19.0.dev2025012410.dist-info/METADATA,sha256=Jk89BafUbkG8kpa-Gs6dPQhkTvx5bvuMigDn-cDlZOY,1857
|
610
|
+
tf_keras_nightly-2.19.0.dev2025012410.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
611
|
+
tf_keras_nightly-2.19.0.dev2025012410.dist-info/top_level.txt,sha256=LC8FK7zHDNKxB17C6lGKvrZ_fZZGJsRiBK23SfiDegY,9
|
612
|
+
tf_keras_nightly-2.19.0.dev2025012410.dist-info/RECORD,,
|
File without changes
|
File without changes
|