-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Keras.io examples conversion gameplan #18468
Comments
Wow! Been contributing to these examples for a long time but never realized that we have so many high-quality examples. Amazing feat! 👏 PS: I will setup keras_core GPU env, and will start working on some of the examples I contributed. Will update the issue accordingly |
Raised a PR to port the example Zero-DCE for low-light image enhancement to |
Raised a PR to port example Low-light image enhancement using MIRNet to |
Raised PR to port example |
Raised a PR to port example to |
I would like to take 'Question Answering with Hugging Face Transformers' task. |
I am facing an issue while running after changes and I have raised an issue for the same #18572. |
I was working on movielens recommendations and raised PR for the same #18690 |
I would like to work on "Text extraction with Bert" stage 1. PS: the status on what has been done already is not up to date in the stage 1 list above. |
"Image Classification using BigTransfer (BiT)" is the task that I would like to take on. Image Classification using BigTransfer (BiT) Note: As of right now, I will focus on Stage 1: the tf.keras backward compatibility check. To make the backend agnostic, the remainder will attempt to work on stage 2. |
Update: Find some issues specifically related to the model at tf.hub (now Kaggle Models). Anyway, I will create a detailed issue of my problems in one or two days. |
"Train a Vision Transformer on small datasets" is the task that I would like to take on next. Train a Vision Transformer on small datasets |
@sitamgithub-MSIT I am already working on this from last couple of days, I had also raised issue which I was facing in this script but now that issue is gone and Stage 1 is already completed. I will raise PR soon. Please select different problem/ example. |
I've just noticed this keras example, Semi-supervised image classification using contrastive pretraining with SimCLR ( link ) has changed significantly, original author @beresandras , updated by @ariG23498. The core contributed part (SimCLR modelling) is replaced with built-in API (why). Also, what is the purpose of class SimCLRTrainer(keras_cv.training.ContrastiveTrainer):
def __init__(self, encoder, augmenter, projector, probe=None, **kwargs):
super().__init__(
encoder=encoder,
augmenter=augmenter,
projector=projector,
probe=probe,
**kwargs,
)
simclr_model = SimCLRTrainer(...) |
That was part of the Keras Sprint. CC: @martin-gorner |
Working on the MixUp augmentation for image classification |
Looks like it (link) is reverted to its original form. |
It seems like it was already converted to Keras 3.0. The above list is not updated, and moreover, on the Keras website, it is showing as Keras 2.0. CC: @fchollet |
Working on the RandAugment for Image Classification for Improved Robustness |
Instead of replacing Keras 2 example with Keras 3, why not keeping both in the code example? As |
We need to convert keras.io examples to work with Keras 3.
This involves two stages:
Stage 1: tf.keras backwards compatibility check
Keras 3 is intended as a drop-in replacement for tf.keras. We expect most examples to work with no code changes other changing the imports (when using TF as the backend). So the first thing to do with a keras.io example is:
python pip_build.py --install
).epochs=1
andsteps_per_epoch=3
, that sort of thing).examples/keras_io/tensorflow/
. PLEASE INCLUDE THE GIT DIFF (diff from the original example to the new file) in the PR description.Note: in some cases this conversion will not be possible. There is some niche functionality that we removed from Keras 3, such as
add_metric
. When hitting such problems, if unable to work around the issue, simply record the problem in a GitHub issue and move on.Stage 2: backend-agnostic conversion
Going one step further, once an example runs with the TF backend, we should seek to replace all TF APIs in the example with backend-agnostic
keras.ops
APIs.In some cases this is not possible. Keras Core does not have backend-agnostic capabilities for custom
train_step
or custom training loops. In such cases, you should convert what is convertible, and then fork the example into 2 separate versions: a TF one and a JAX one, using APIs from each framework to implement the low-level functionality.Keep in mind that it's ok to use TF APIs for data I/O and preprocessing. We only aim to convert modeling and training APIs -- all data preprocessing can stay as-is even if it uses TF. TF is the only feature-complete framework when it comes to data preprocessing, and generally the only viable option for many use cases.
Note on Keras preprocessing layers and tf.data: you can't use Keras 3 preprocessing layers in a tf.data pipeline when using a backend that is not TF. As a result, if you need to use Keras preprocessing layers in tf.data, import them from tf.keras.
Once you have converted an example to use backend-agnostic APIs and run with JAX and TF, open a PR to commit it:
examples/keras_io/tf/
(it should replace the existing one if it is there) orexamples/keras_io/jax/
if it's backend-specific.examples/keras_io/
if it's backend-agnostic.Let's go!
Assignment - stage 1: conversion to Keras 3 with TF backend
CV
NLP
Structured data
Timeseries
Generative
Other
List of examples with significant incompatibilities
compiled_loss
/compiled_metrics
.List of examples that cannot be converted at all
tf.keras.layers.experimental.RandomFourierFeatures
, not included in Keras Core.The text was updated successfully, but these errors were encountered: