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

[QUESTION] Embedding and Ranking #88

Open
zeyaddeeb opened this issue Jan 8, 2024 · 1 comment
Open

[QUESTION] Embedding and Ranking #88

zeyaddeeb opened this issue Jan 8, 2024 · 1 comment

Comments

@zeyaddeeb
Copy link

If I have a model like this:

class Model(torch.nn.Module):
...
        self.user_embed = torch.nn.Embedding(n_users, n_factors)
...

What would be the best way to implement def learn_one... given that new users get added from a stream?

@kulbachcedric
Copy link
Collaborator

Hi @zeyaddeeb,
I would stick to the regression learn_one method:

def learn_one(self, x: dict, y: RegTarget, **kwargs) -> "Regressor": if not self.module_initialized: self.kwargs["n_features"] = len(x) self.initialize_module(**self.kwargs) x_t = dict2tensor(x, self.device) y_t = float2tensor(y, device=self.device) self._learn(x_t, y_t) return self

The helper methods _learn, dict2tensor and float2tensor might help you as well.

Best
Cedric

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

No branches or pull requests

2 participants