From 530a1cf343433a655e5047a246fc1d9991b0d86d Mon Sep 17 00:00:00 2001 From: divyashreepathihalli Date: Fri, 27 Sep 2024 18:38:36 +0000 Subject: [PATCH 1/5] update jax version --- requirements-jax-cuda.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-jax-cuda.txt b/requirements-jax-cuda.txt index 599a797cc7..a5b1df5062 100644 --- a/requirements-jax-cuda.txt +++ b/requirements-jax-cuda.txt @@ -10,6 +10,6 @@ torchvision>=0.16.0 # Jax with cuda support. # TODO: 0.4.24 has an updated Cuda version breaks Jax CI. --find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html -jax[cuda12_pip]==0.4.23 +jax[cuda12_pip]==0.4.28 -r requirements-common.txt From 69b40075a3f8dff3710b3873486d70acd0285a26 Mon Sep 17 00:00:00 2001 From: divyashreepathihalli Date: Fri, 27 Sep 2024 18:42:17 +0000 Subject: [PATCH 2/5] remove keras 2 from gpu tests --- .kokoro/github/ubuntu/gpu/build.sh | 11 ++---- .../github/ubuntu/gpu/keras2/continuous.cfg | 34 ------------------- .../github/ubuntu/gpu/keras2/presubmit.cfg | 34 ------------------- 3 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 .kokoro/github/ubuntu/gpu/keras2/continuous.cfg delete mode 100644 .kokoro/github/ubuntu/gpu/keras2/presubmit.cfg diff --git a/.kokoro/github/ubuntu/gpu/build.sh b/.kokoro/github/ubuntu/gpu/build.sh index 6ab351b3f9..ca76446442 100644 --- a/.kokoro/github/ubuntu/gpu/build.sh +++ b/.kokoro/github/ubuntu/gpu/build.sh @@ -32,14 +32,7 @@ nvcc --version cd "src/github/keras-hub" pip install -U pip setuptools psutil -if [ "${KERAS2:-0}" == "1" ] -then - echo "Keras2 detected." - pip install -r requirements-common.txt --progress-bar off --timeout 1000 - pip install tensorflow-text==2.15 tensorflow[and-cuda]~=2.15 keras-core \ - --timeout 1000 - -elif [ "$KERAS_BACKEND" == "tensorflow" ] +if [ "$KERAS_BACKEND" == "tensorflow" ] then echo "TensorFlow backend detected." pip install -r requirements-tensorflow-cuda.txt --progress-bar off \ @@ -67,4 +60,4 @@ then else pytest keras_hub --check_gpu --run_large \ --cov=keras-hub -fi \ No newline at end of file +fi diff --git a/.kokoro/github/ubuntu/gpu/keras2/continuous.cfg b/.kokoro/github/ubuntu/gpu/keras2/continuous.cfg deleted file mode 100644 index cfceee0de8..0000000000 --- a/.kokoro/github/ubuntu/gpu/keras2/continuous.cfg +++ /dev/null @@ -1,34 +0,0 @@ -build_file: "keras-hub/.kokoro/github/ubuntu/gpu/build.sh" - -action { - define_artifacts { - regex: "**/sponge_log.log" - regex: "**/sponge_log.xml" - } -} - -env_vars: { - key: "KERAS2" - value: "1" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73361 - keyname: "keras_kaggle_username" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73361 - keyname: "keras_kaggle_secret_key" - } - } -} - -# Set timeout to 60 mins from default 180 mins -timeout_mins: 60 \ No newline at end of file diff --git a/.kokoro/github/ubuntu/gpu/keras2/presubmit.cfg b/.kokoro/github/ubuntu/gpu/keras2/presubmit.cfg deleted file mode 100644 index cfceee0de8..0000000000 --- a/.kokoro/github/ubuntu/gpu/keras2/presubmit.cfg +++ /dev/null @@ -1,34 +0,0 @@ -build_file: "keras-hub/.kokoro/github/ubuntu/gpu/build.sh" - -action { - define_artifacts { - regex: "**/sponge_log.log" - regex: "**/sponge_log.xml" - } -} - -env_vars: { - key: "KERAS2" - value: "1" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73361 - keyname: "keras_kaggle_username" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73361 - keyname: "keras_kaggle_secret_key" - } - } -} - -# Set timeout to 60 mins from default 180 mins -timeout_mins: 60 \ No newline at end of file From 6b6b5b7f49d39390d073c61a3e4bef11eb29c142 Mon Sep 17 00:00:00 2001 From: divyashreepathihalli Date: Fri, 27 Sep 2024 18:46:26 +0000 Subject: [PATCH 3/5] update comment --- requirements-jax-cuda.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-jax-cuda.txt b/requirements-jax-cuda.txt index a5b1df5062..222e4400b1 100644 --- a/requirements-jax-cuda.txt +++ b/requirements-jax-cuda.txt @@ -8,7 +8,7 @@ torch>=2.1.0 torchvision>=0.16.0 # Jax with cuda support. -# TODO: 0.4.24 has an updated Cuda version breaks Jax CI. +# Keep same version as Keras repo. --find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html jax[cuda12_pip]==0.4.28 From 06aec0d985b13a35626c8352ef99cb416f0ed953 Mon Sep 17 00:00:00 2001 From: divyashreepathihalli Date: Sat, 28 Sep 2024 04:43:58 +0000 Subject: [PATCH 4/5] update readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 876c147808..9f4b3ff9a5 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,12 @@ For more in depth guides and examples, visit [keras.io/keras_nlp](https://keras.io/keras_nlp/). ## Installation +KerasHub that is currently available on PiPy is a pre release version. +For a stable and supported experience, please use KerasNLP version 0.15.1. You +can install it using: +``` +pip install keras-nlp==0.15.1 +``` To install the latest KerasHub release with Keras 3, simply run: From 90cf1bf416e25689e71986770d09319e030949b9 Mon Sep 17 00:00:00 2001 From: divyashreepathihalli Date: Mon, 30 Sep 2024 17:47:55 +0000 Subject: [PATCH 5/5] address review comments --- README.md | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9f4b3ff9a5..cdbce8b532 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,13 @@ We welcome contributions. ## Quickstart -Fine-tune BERT on IMDb movie reviews: +Fine-tune a BERT classifier on IMDb movie reviews: ```python import os os.environ["KERAS_BACKEND"] = "jax" # Or "tensorflow" or "torch"! -import keras_hub +import keras_nlp import tensorflow_datasets as tfds imdb_train, imdb_test = tfds.load( @@ -65,12 +65,14 @@ imdb_train, imdb_test = tfds.load( as_supervised=True, batch_size=16, ) + # Load a BERT model. -classifier = keras_hub.models.Classifier.from_preset( +classifier = keras_nlp.models.Classifier.from_preset( "bert_base_en", num_classes=2, activation="softmax", ) + # Fine-tune on IMDb movie reviews. classifier.fit(imdb_train, validation_data=imdb_test) # Predict two new examples. @@ -82,28 +84,24 @@ For more in depth guides and examples, visit [keras.io/keras_nlp](https://keras.io/keras_nlp/). ## Installation -KerasHub that is currently available on PiPy is a pre release version. -For a stable and supported experience, please use KerasNLP version 0.15.1. You -can install it using: -``` -pip install keras-nlp==0.15.1 -``` -To install the latest KerasHub release with Keras 3, simply run: +KerasHub is currently in pre-release. Note that pre-release versions may +introduce breaking changes to the API in future versions. For a stable and +supported experience, we recommend installing `keras-nlp` version 0.15.1: -``` -pip install --upgrade keras-hub +```bash +pip install keras-nlp==0.15.1 ``` -To install the latest nightly changes for both KerasHub and Keras, you can use -our nightly package. +To try out the latest pre-release version of KerasHub, you can use +our nightly package: -``` -pip install --upgrade keras-hub-nightly +```bash +pip install keras-hub-nightly ``` -Note that currently, installing KerasHub will always pull in TensorFlow for use -of the `tf.data` API for preprocessing. Even when pre-processing with `tf.data`, +KerasHub currently requires TensorFlow to be installed for use of the +`tf.data` API for preprocessing. Even when pre-processing with `tf.data`, training can still happen on any backend. Read [Getting started with Keras](https://keras.io/getting_started/) for more @@ -133,15 +131,15 @@ import keras_hub ``` > [!IMPORTANT] -> Make sure to set the `KERAS_BACKEND` before import any Keras libraries, it -> will be used to set up Keras when it is first imported. +> Make sure to set the `KERAS_BACKEND` **before** importing any Keras libraries; +> it will be used to set up Keras when it is first imported. ## Compatibility We follow [Semantic Versioning](https://semver.org/), and plan to provide backwards compatibility guarantees both for code and saved models built with our components. While we continue with pre-release `0.y.z` development, we -may break compatibility at any time and APIs should not be consider stable. +may break compatibility at any time and APIs should not be considered stable. ## Disclaimer