Skip to content

Fix loading of single-input/output models (closes #461) - #463

Merged
Dobiasd merged 3 commits into
masterfrom
fix-single-input-model-load
Apr 29, 2026
Merged

Fix loading of single-input/output models (closes #461)#463
Dobiasd merged 3 commits into
masterfrom
fix-single-input-model-load

Conversation

@Dobiasd

@Dobiasd Dobiasd commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes the README's minimal example failing with Error: invalid format for inbound node (issue The example from the README fails #461).
  • Keras serializes a single connection in input_layers/output_layers as a flat ["layer", node_idx, tensor_idx] and multiple connections as a list of such triples. The previous code used create_vector for both, which iterated each element of the flat form and tried to parse a string/int as an inbound node.
  • Adds a small helper that detects the flat single-connection form and wraps it appropriately, leaving the multi-connection path unchanged.

Test plan

  • Reproduced the bug locally with the README example (TF 2.20 / Keras 3.11) — got invalid format for inbound node.
  • After the fix, the README example loads, runs the embedded test, and produces the expected softmax output.
  • Verified that an existing multi-input/single-output model still loads and predicts correctly.

🤖 Generated with Claude Code

Dobiasd and others added 3 commits April 29, 2026 06:50
Keras serializes a single connection in input_layers/output_layers as
a flat ["layer", node_idx, tensor_idx], but multiple connections as a
list of such triples. The previous code used create_vector for both,
which iterated each element of the flat form and tried to parse a
string/int as an inbound node, failing with "invalid format for
inbound node" - the exact error from the README example.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Newer Keras versions serialize a single input/output as a flat triple
["layer", node_idx, tensor_idx] instead of a list containing one such
triple. The existing readme_example_main test exercises a single-input
model, but only catches this when CI runs against a Keras version that
already emits the flat form. Post-process the readme example JSON into
flat form and load it from a new test so this code path is covered on
any Keras version.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the JSON post-processing helper and its test. Coverage will instead
come from a follow-up CI bump to a Keras version that natively emits the
flat input_layers/output_layers form, at which point the existing
readme_example_main test exercises this code path against real Keras
output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dobiasd
Dobiasd merged commit 4f1a3c3 into master Apr 29, 2026
4 checks passed
@Dobiasd
Dobiasd deleted the fix-single-input-model-load branch April 29, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant