keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.15k stars 19.49k forks source link

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

Open martin-gorner opened 1 year ago

martin-gorner commented 1 year ago

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):

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 commented 1 year ago

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.