Skip to content

fix(policy): force legacy Keras for TF >= 2.16 compatibility#514

Open
thias15 wants to merge 1 commit into
masterfrom
thias15/policy-tf-legacy-keras
Open

fix(policy): force legacy Keras for TF >= 2.16 compatibility#514
thias15 wants to merge 1 commit into
masterfrom
thias15/policy-tf-legacy-keras

Conversation

@thias15
Copy link
Copy Markdown
Collaborator

@thias15 thias15 commented May 9, 2026

Summary

TF 2.16 switched the default Keras to Keras 3, which breaks the existing Keras 2 model definitions in policy/openbot/models.py with the layer ... has never been called and thus has no defined output for users who deviate from the pinned 2.9.x environment.

Setting TF_USE_LEGACY_KERAS=1 in policy/openbot/__init__.py (which runs before any submodule imports tensorflow) restores Keras 2 behavior, so policy training works on newer TF versions without forcing users to downgrade.

Fixes #447. Workaround originally identified by @sparta-2024 in that issue thread.

Test plan

  • Train a policy on TF 2.9 (the pinned version) and confirm no behavior change.
  • Train a policy on TF 2.16 / 2.17 and confirm the MLP error no longer occurs.

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.

the layer MLP has never been called and thus has no defined output

1 participant