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

Bert training with TPU does not work on Keras Core #18422

Open
martin-gorner opened this issue Aug 3, 2023 · 1 comment
Open

Bert training with TPU does not work on Keras Core #18422

martin-gorner opened this issue Aug 3, 2023 · 1 comment
Labels

Comments

@martin-gorner
Copy link
Contributor

martin-gorner commented Aug 3, 2023

Repro notebook: https://www.kaggle.com/code/alexia/kerasnlp-starter-notebook-contradictory-dearwatson

This notebook is configured to use keras_nlp and standard tf.keras. It works perfectly.

If reconfigured to use keras_nlp with Keras Core the model stops working (failing version here):

  • it displays non-sensical accuracies > 1 during training
  • eval accuracy the same as if the mode was doing random predictions
  • .predict returns predictions of the wrong shape (shape=(n,) instead of (n,3)
  • therefore the final np.argmax(predictions, axis=1) fails.
  • there is nan in the predictions

The behavior does not change when pip installing form GitHub master (latest version) rather than PyPi (latest published package) for both Keras Core and KerasNLP

The config I used to make the model fail:

!pip install keras-core
import os
os.environ['KERAS_BACKEND'] = 'tensorflow'
import keras_core as keras
@sampathweb
Copy link
Collaborator

sampathweb commented Aug 3, 2023

Yes. I confirm the problem of accuracies > 1 in TPU env with keras-core backend. The notebook works fine in GPU env with keras-core backend.

@fchollet fchollet transferred this issue from keras-team/keras-core Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants