keras icon indicating copy to clipboard operation
keras copied to clipboard

🚀 Contributing to Keras 🚀

Open fchollet opened this issue 1 year ago • 52 comments

Keras 3 is a high-velocity open-source project. We welcome contributions! Here's what you can do:

Take up one of these items:

Here are some features that we'd love to see implemented by the Keras community:

  • Add cuDNN support for PyTorch RNNs by implementing keras/backend/torch/rnn.py:cudnn_lstm and cudnn_gru.
  • Add support for ONNX in model.export() and ExportArchive. On the TF and JAX side, we can transit via SavedModel. On the torch side, we can do a native export.
  • Add rematerialization support to KerasHub LLMs.
  • Contribute to the MLX backend. We have a mlx branch on the repo, which does not yet have full operation converge in keras/src/backend/mlx/. Add missing ops and help get the new MLX backend closer to the finish line!

Check out TODOs

There are various TODOs in the codebase. You can do a quick search (e.g. grep "TODO" keras/ -r) and see if anything looks interesting to you. Make sure to ask in this thread before starting work on any item!

Bring new pretrained model implementations to KerasHub

The Keras ecosystem package KerasHub is looking for contributors! If you'd like to port a pretrained model implementation to the Keras ecosystem, that's a great project to join.

Convert an example from keras.io to Keras 3

keras.io/examples offers many great tutorials, but many of them are still based on Keras 2. We'd like to bring over in the shiny new world of multi-framework ML.

There are two stages of conversion:

  1. Converting a Keras 2 example so that it can run on Keras 3 with the TF backend.
  2. Converting a Keras 2 example so that it can run on Keras 3 with any backend.

If you see an example marked as "v2" on keras.io/examples, you can open a PR on keras-team/keras-io to convert it to Keras 3. Keep in mind:

  • Start by only including the Python file in the PR, not the md and ipynb files, because you may have to regenerate those after review comments come in.
  • To convert the code, you can refer to the Keras 3 migration guide.

Add new examples to keras.io

Have a great ML project you'd like to use to teach others about ML? You can add a new tutorial on keras.io/examples! Just follow the instructions at keras-team/keras-io.

Increase test coverage

Keras doesn't have 100% code coverage in unit tests just yet. You can try to run a code coverage tool like codecov and see if there are any unit tests you could add to improve Keras.

fchollet avatar Jul 14 '23 22:07 fchollet

Taking up the Moving Dataset utils task as a priority! Should I make a draft PR?

suvadityamuk avatar Jul 16 '23 03:07 suvadityamuk

Taking up the Moving Dataset utils task as a priority! Should I make a draft PR?

No need for a draft -- you can just send the PR when you have something you want a review on. Thank you!

fchollet avatar Jul 16 '23 06:07 fchollet

@fchollet regarding dataset utils, since all three frameworks tensorflow , torch and jax have their own data-loading modules or have specific classes to provide this utilities, but currently it is relying on tf.keras can only accept either tf.Dataset or regular python structures as of now, so dropping it means that we either support similar logic for individual framework or we accept generic structures + framework specific data-holder and convert it to a unified keras data-holder and then perform similar operations.

since in first option we import framework specific modules and built on top but these will stay in keras.backend but in option two we we don't need to touch keras.backend' we only made changes to keras.utils`. Can you please let me know your thoughts on this. 😊

@suvadityamuk can please also share your thoughts in which direction you are choosing. 😊

asingh9530 avatar Jul 16 '23 12:07 asingh9530

@asingh9530

I'm currently looking into trying to move the tf.keras-specific data utils from the original keras-team/keras space to this space, with all implementations intact. The only thing I'm adding is support to handle torch.utils.data.Dataset along with it, since that's a major focus.

suvadityamuk avatar Jul 16 '23 12:07 suvadityamuk

@suvadityamuk Thanks for responding, since this will be a big change let's track it in a new issue with specific changes needed to be done since even in keras the utils are for tf.Dataset let's say Iterators, batched etc. How about I'll add you there and work on this.

asingh9530 avatar Jul 16 '23 13:07 asingh9530

Hello, I am rather new w.r.t contributions, so I may ask a rather silly question : are publicly exported functions those decorated with @keras_core_export ?

dranaivo avatar Jul 24 '23 21:07 dranaivo

so I may ask a rather silly question : are publicly exported functions those decorated with @keras_core_export

Yes, that's right. The public API is programmatically generated using those decorators.

fchollet avatar Jul 25 '23 22:07 fchollet

Can someone help me with keras_core/layers/layer.py:439: # TODO: handle layout.What does it mean to handle the layout?

vulkomilev avatar Aug 24 '23 20:08 vulkomilev

@fchollet bump

vulkomilev avatar Aug 29 '23 17:08 vulkomilev

Can someone help me with keras_core/layers/layer.py:439: # TODO: handle layout.What does it mean to handle the layout?

This was referring to the implementation of a future distribution API -- but this has been handled since. Nothing to do here.

fchollet avatar Sep 16 '23 21:09 fchollet

Hi,

I am willing to take a shot at the solve operation implementation, still setting up a development environment. One clarification question. What is the error value for a matrix input that is singular (i.e., no inverse matrix exists), not full rank, or not square? To be sure, I look forward to contributing as a hobby and will circle back when I have something satisfactory for review.

Thanks, bf

BenjiFischman avatar Sep 16 '23 23:09 BenjiFischman

Hello @fchollet,

I wanted to reach out and update you on the progress I've made with the ERF function. I've made significant changes to the code and have already uploaded them to my forked repository. I'm confident that these updates will improve the function's performance, but please take a look and let me know if there's anything else you'd like me to do.

1.) Changes to keras-core/ops/math.py https://github.com/sqali/keras-core/blob/6485433201e8a935f462aca191bc37dd7cf00c30/keras_core/ops/math.py#L934-L966

2.) Changes to keras-core/ops/math_test.py https://github.com/sqali/keras-core/blob/6485433201e8a935f462aca191bc37dd7cf00c30/keras_core/ops/math_test.py#L840-L868

3.) Changes to keras-core/backend/tensorflow/math.py https://github.com/sqali/keras-core/blob/6485433201e8a935f462aca191bc37dd7cf00c30/keras_core/backend/tensorflow/math.py#L244-L245

sqali avatar Sep 17 '23 12:09 sqali

I am willing to take a shot at the solve operation implementation, still setting up a development environment. One clarification question. What is the error value for a matrix input that is singular (i.e., no inverse matrix exists), not full rank, or not square? To be sure, I look forward to contributing as a hobby and will circle back when I have something satisfactory for review.

solve exists in all 3 backends, so most likely we just want to wrap it. You can check what the error is for a singular matrix for each backend. We should raise a similar error.

fchollet avatar Sep 17 '23 19:09 fchollet

I wanted to reach out and update you on the progress I've made with the ERF function. I've made significant changes to the code and have already uploaded them to my forked repository. I'm confident that these updates will improve the function's performance, but please take a look and let me know if there's anything else you'd like me to do.

It will also need to be implemented for the JAX, torch, and numpy backends. Can you open a PR? We can carry on on the PR.

fchollet avatar Sep 17 '23 19:09 fchollet

Sure, I will do that. Thanks.

sqali avatar Sep 18 '23 00:09 sqali

@fchollet , I am interested in contributing to Keras Core. I went through the description above and interested to work on this item "Convert an example from keras.io to Keras Core". Could you please guide me on the steps to follow . Do I need to raise a new pull request. Thank you

jayaBalaR avatar Sep 18 '23 15:09 jayaBalaR

@fchollet I can take up erf implementation, any specific condition you want in the implementation if not I will follow implementation guideline of rest of operations.

asingh9530 avatar Sep 18 '23 16:09 asingh9530

I can take up the scan op/operation in jax

vulkomilev avatar Sep 18 '23 17:09 vulkomilev

Hi @asingh9530 ,

I have already opened a PR for erf and working on it. Thanks.

sqali avatar Sep 18 '23 17:09 sqali

Hi people,

I think I took care of most of the necessary changes. Still struggling on how to run a unit test locally with respect to my forked branch. Happy to open a PR if this is helpful. In addition, please advise on how to run a test, import a built whl binary into a Jupyter notebook, and next steps for agnostic solve.

Thanks, bf

BenjiFischman avatar Sep 18 '23 20:09 BenjiFischman

@fchollet I'm working on the keras_core/saving/saving_lib.py. TODO: if h5 filepath is remote, create the file in a temporary directory then upload it. Should I use the requests library to posts the file on the required remote filepath ?

pranavvp16 avatar Sep 19 '23 11:09 pranavvp16

I'm working on the keras_core/saving/saving_lib.py. TODO: if h5 filepath is remote, create the file in a temporary directory then upload it. Should I use the requests library to posts the file on the required remote filepath ?

Please only use Python stdlib utilities for this. Thanks!

fchollet avatar Sep 19 '23 16:09 fchollet

I am interested in contributing to Keras Core. I went through the description above and interested to work on this item "Convert an example from keras.io to Keras Core". Could you please guide me on the steps to follow . Do I need to raise a new pull request.

Here's the full context and the process to follow: https://github.com/keras-team/keras/issues/18468

fchollet avatar Sep 19 '23 16:09 fchollet

I can take up the scan op/operation in jax

Sure, sounds good! It will need to be implemented in all 4 backends though.

I think I took care of most of the necessary changes. Still struggling on how to run a unit test locally with respect to my forked branch. Happy to open a PR if this is helpful. In addition, please advise on how to run a test, import a built whl binary into a Jupyter notebook, and next steps for agnostic solve.

It will need much more extensive unit testing. You can run unit tests locally via pytest.

fchollet avatar Sep 19 '23 16:09 fchollet

I'm working on the keras_core/saving/saving_lib.py. TODO: if h5 filepath is remote, create the file in a temporary directory then upload it. Should I use the requests library to posts the file on the required remote filepath ?

Please only use Python stdlib utilities for this. Thanks!

thanks, last question what can be a good example for remote file path.

pranavvp16 avatar Sep 19 '23 17:09 pranavvp16

thanks, last question what can be a good example for remote file path.

Something like gcs://...

fchollet avatar Sep 19 '23 20:09 fchollet

I am interested in contributing to Keras Core. I went through the description above and interested to work on this item "Convert an example from keras.io to Keras Core". Could you please guide me on the steps to follow . Do I need to raise a new pull request.

Here's the full context and the process to follow: keras-team/keras#18468

Thank you. I will check the link and start working

jayaBalaR avatar Sep 20 '23 11:09 jayaBalaR

Thanks @fchollet! Debugging more unit tests now, I commented the latest errors I have been seeing in the math._test.py file here. Any ideas to get a more deterministic response from tensorflow are much appreciated.

BenjiFischman avatar Sep 20 '23 15:09 BenjiFischman

I could port some of the listed examples from tf.keras to Keras Core. Out of the outstanding examples, are there any, in particular, you would first like to see ported to Keras Core?

pranav-vempati avatar Sep 21 '23 00:09 pranav-vempati

@fchollet what to do if some framework do not have the feature or it is work in progress( like scan and pytorch https://github.com/pytorch/pytorch/issues/50688)?

vulkomilev avatar Sep 21 '23 18:09 vulkomilev