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

Adding: Numpy Backend #483

Merged
merged 64 commits into from
Jul 18, 2023
Merged

Adding: Numpy Backend #483

merged 64 commits into from
Jul 18, 2023

Conversation

ariG23498
Copy link
Collaborator

In this PR I will continue working on the Numpy Backend for Keras Core

@ariG23498
Copy link
Collaborator Author

ariG23498 commented Jul 15, 2023

Todos:

  • Implementing rnn for the backend.

@ariG23498 ariG23498 changed the base branch from aritra-np-backend to main July 16, 2023 17:59
@ariG23498 ariG23498 requested review from fchollet and ianstenbit July 17, 2023 05:41
Copy link
Contributor

@ianstenbit ianstenbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I suppose if we're going to add Numpy as a backend we should also add CI for it -- this just means we'll need to add numpy to the backend list in actions.yaml

keras_core/applications/applications_test.py Outdated Show resolved Hide resolved
keras_core/backend/__init__.py Outdated Show resolved Hide resolved
keras_core/backend/numpy/core.py Outdated Show resolved Hide resolved
Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 👍

keras_core/backend/numpy/core.py Outdated Show resolved Hide resolved
keras_core/backend/numpy/trainer.py Outdated Show resolved Hide resolved
def fit(self):
raise NotImplementedError("Trainer not implemented for NumPy backend.")

def predict(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term it could be possible to implement predict and evaluate.

@@ -49,3 +49,11 @@ def __getattr__(self, name):
from keras_core.backend import torch as torch_backend

return getattr(torch_backend, name)
if self._backend == "numpy":
# TODO (ariG23498):
# The import `from keras_core.backend import numpy as numpy_backend`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this the case?

Copy link
Collaborator Author

@ariG23498 ariG23498 Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am usure about this. It might have to do with numpy backend having a numpy file on its own (which somehow creates the error).

keras_core/layers/layer.py Outdated Show resolved Hide resolved
@fchollet
Copy link
Contributor

Please run sh shell/format.sh to format the code.

@ariG23498 ariG23498 requested review from ianstenbit and fchollet July 18, 2023 09:53
@ariG23498
Copy link
Collaborator Author

I am usure why the JAX tests fail.

@fchollet
Copy link
Contributor

Are you able to run them locally?

They're timing out rather than failing. This is possibly normal.

@ariG23498
Copy link
Collaborator Author

Are you able to run them locally?

They're timing out rather than failing. This is possibly normal.

Yep! Tried running the test suite with JAX and it ran fine.

keras_core/backend/numpy/rnn.py Outdated Show resolved Hide resolved
keras_core/backend/numpy/rnn.py Outdated Show resolved Hide resolved
@ariG23498
Copy link
Collaborator Author

Removed the debug statements! Sorry about that 😅

@fchollet
Copy link
Contributor

I think we should be good to merge. Thanks for the great contribution!

@fchollet fchollet merged commit 37981b9 into keras-team:main Jul 18, 2023
adi-kmt pushed a commit to adi-kmt/keras-core that referenced this pull request Jul 21, 2023
* chore: adding numpy backend

* creview comments

* review comments

* chore: adding math

* chore: adding random module

* chore: adding ranndom in init

* review comments

* chore: adding numpy and nn for numpy backend

* chore: adding generic pool, max, and average pool

* chore: adding the conv ops

* chore: reformat code and using jax for conv and pool

* chore:  added self value

* chore: activation tests pass

* chore: adding post build method

* chore: adding necessaity methods to the numpy trainer

* chore: fixing utils test

* chore: fixing losses test suite

* chore: fix backend tests

* chore: fixing initializers test

* chore: fixing accuracy metrics test

* chore: fixing ops test

* chore: review comments

* chore: init with image and fixing random tests

* chore: skipping random seed set for numpy backend

* chore: adding single resize image method

* chore: skipping tests for applications and layers

* chore: skipping tests for models

* chore: skipping testsor saving

* chore: skipping tests for trainers

* chore:ixing one hot

* chore: fixing vmap in numpy and metrics test

* chore: adding a wrapper to numpy sum, started fixing layer tests

* fix: is_tensor now accepts numpy scalars

* chore: adding draw seed

* fix: warn message for numpy masking

* fix: checking whether kernel are tensors

* chore: adding rnn

* chore: adding dynamic backend for numpy

* fix: axis cannot be None for normalize

* chore: adding jax resize for numpy image

* chore: adding rnn implementation in numpy

* chore: using pytest fixtures

* change: numpy import string

* chore: review comments

* chore: adding numpy to backend list of github actions

* chore: remove debug print statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants