Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Recommend Setting TF_USE_LEGACY_KERAS=1 to Fix Behavior Change After Upgrading to Keras 3 #163

Closed
Lw-Cui opened this issue Oct 3, 2024 · 1 comment

Comments

@Lw-Cui
Copy link

Lw-Cui commented Oct 3, 2024

Upgrading from TensorFlow 2.15 to 2.16 introduces inconsistencies due to the shift from Keras 2 to Keras 3. TensorFlow 2.15 uses Keras 2, while TensorFlow 2.16 integrates Keras 3. This change leads to significant differences in model behavior within this repository, which is built upon Keras 2. However, platforms like Google Colab and Kaggle notebooks already use Keras 3 by default.

Describe the bug

In Chapter 16, "Encoder-Decoder Network for Neural Machine Translation," the model achieves an accuracy of approximately 60% when using Keras 2, as documented in the repository. However, running the same code on Colab or Kaggle with Keras 3 results in an accuracy drop to around 10%.

For more details about this discrepancy, please refer to this issue.

Recommended Action

To maintain consistency and prevent unexpected issues, I recommend explicitly setting the environment variable TF_USE_LEGACY_KERAS=1 to continue using Keras 2.

@Lw-Cui Lw-Cui changed the title [BUG] Recommend Setting TF_USE_LEGACY_KERAS=1 to Fix Accuracy Drop After Upgrading to Keras 3 [BUG] Recommend Setting TF_USE_LEGACY_KERAS=1 to Fix Behavior Change After Upgrading to Keras 3 Oct 3, 2024
@ageron
Copy link
Owner

ageron commented Oct 6, 2024

Thanks for your suggestion, I was struggling to update this chapter to Keras 3, but it's pretty much impossible for now, because things like Stateful RNNs, ragged tensors, TF hub models, and more are buggy or just not supported yet. Using legacy Keras just works. 👍

@ageron ageron closed this as completed in bd1ee43 Oct 6, 2024
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

No branches or pull requests

2 participants