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 GRU4Rec example #20

Merged
merged 7 commits into from
Feb 9, 2025
Merged

Conversation

abheesht17
Copy link
Collaborator

Note: The loss in the TFRS example does not converge. So, changed a few things.

Copy link
Collaborator

@hertschuh hertschuh 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! There was a lot to do with the data processing.

Comment on lines 15 to 17
import os

os.environ["KERAS_BACKEND"] = "jax"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason to do that? At some point I was thinking we can write tests to run these automatically with each backend. But I never got around to doing that. But for it to work, the backend has to not be set within the file.

Did you test with TF and Torch too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, working for all backends!


import keras_rs

keras.utils.set_random_seed(42)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason to do that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I set the seed when I was testing training with different hyperparameters, etc. Can remove/keep it, doesn't matter which way

[basic retrieval](https://github.com/keras-team/keras-rs/blob/main/examples/basic_retrieval.py)
example, we are going to use the MovieLens dataset.

The dataset preparation step is fairly involved. The original ratings dataset
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for porting all the dataset massaging stuff here. That was most of the work I imagine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, pretty much. I was trying to not do the conversion to Pandas DF, and somehow use tf.data.group_by_window. At some point, I gave up xD

import keras
import pandas as pd
import tensorflow as tf # Needed only for the dataset
from keras import ops
Copy link
Collaborator

Choose a reason for hiding this comment

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

Further down, you're sometimes using keras.ops.x and sometimes ops.x. Make it consistent. I don't think this import is necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, yeah. Sorry about that!

@abheesht17 abheesht17 requested a review from hertschuh January 31, 2025 09:37
@hertschuh hertschuh merged commit 8a907a6 into keras-team:main Feb 9, 2025
5 checks passed
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.

2 participants