Skip to content

Commit 802299e

Browse files
Revert "Fixes inconsistent serialization logic for inputs (#20993)" (#21336)
This reverts commit a8ccaf3.
1 parent de9cf25 commit 802299e

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

keras/src/models/functional.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ def map_tensors(tensors):
621621

622622
input_tensors = map_tensors(functional_config["input_layers"])
623623
output_tensors = map_tensors(functional_config["output_layers"])
624+
if isinstance(input_tensors, list) and len(input_tensors) == 1:
625+
input_tensors = input_tensors[0]
624626
if isinstance(output_tensors, list) and len(output_tensors) == 1:
625627
output_tensors = output_tensors[0]
626628

keras/src/models/functional_test.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from keras.src.models import Functional
1818
from keras.src.models import Model
1919
from keras.src.models import Sequential
20-
from keras.src.models.model import model_from_json
2120

2221

2322
class FunctionalTest(testing.TestCase):
@@ -274,19 +273,6 @@ def test_restored_multi_output_type(self, out_type):
274273
out_val = model_restored(Input(shape=(3,), batch_size=2))
275274
self.assertIsInstance(out_val, out_type)
276275

277-
def test_restored_nested_input(self):
278-
input_a = Input(shape=(3,), batch_size=2, name="input_a")
279-
x = layers.Dense(5)(input_a)
280-
outputs = layers.Dense(4)(x)
281-
model = Functional([[input_a]], outputs)
282-
283-
# Serialize and deserialize the model
284-
json_config = model.to_json()
285-
restored_json_config = model_from_json(json_config).to_json()
286-
287-
# Check that the serialized model is the same as the original
288-
self.assertEqual(json_config, restored_json_config)
289-
290276
@pytest.mark.requires_trainable_backend
291277
def test_layer_getters(self):
292278
# Test mixing ops and layers

0 commit comments

Comments
 (0)