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

Add TorchModuleWrapper #779

Merged
merged 11 commits into from
Aug 30, 2023
Merged

Conversation

soumik12345
Copy link
Contributor

Add the implementation of TorchModuleWarpper for wrapping both vanilla and lazy torch.nn.Modules as keras_core.layers.Layers.

Linked Issue: #604

Linked Notebook:

@soumik12345
Copy link
Contributor Author

Hi @fchollet
I am encountering this import error while trying to import Variable.

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! Excited about this functionality

keras_core/backend/torch/torch_module_wrapper.py Outdated Show resolved Hide resolved
Copy link
Member

@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.

Thanks for the PR!

keras_core/backend/torch/torch_module_wrapper.py Outdated Show resolved Hide resolved
keras_core/backend/torch/torch_module_wrapper.py Outdated Show resolved Hide resolved
keras_core/backend/torch/torch_module_wrapper.py Outdated Show resolved Hide resolved
@soumik12345 soumik12345 changed the title Add TorchModuleWarpper Add TorchModuleWrapper Aug 26, 2023
@sachinprasadhs sachinprasadhs added the stat:awaiting keras-eng Awaiting response from Keras engineer label Aug 29, 2023
@soumik12345
Copy link
Contributor Author

Hi @fchollet
Here are 2 issues with the current code:

  1. During model.call for lazy torch modules, an error is encountered, stating
TypeError: Exception encountered when calling LazyClassifier.call().

missing a required argument: 'inputs'

Is the compute_output_spec function used incorrectly?

  1. During model.fit another error is encountered for lazy modules, stating
RuntimeError: Unable to automatically build the model

Here's a colab to reportduce the issues: https://colab.research.google.com/drive/1UO8uY86Ff-lNq5_7vKeLAb5sK99UFDWJ?usp=sharing

@fchollet
Copy link
Member

Thanks. I'll take it over.

@fchollet fchollet merged commit 5735fad into keras-team:main Aug 30, 2023
6 checks passed
@soumik12345 soumik12345 deleted the feat/torch-module-wrapper branch August 30, 2023 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting keras-eng Awaiting response from Keras engineer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants