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

How to make Tensorrec have stable results #154

Open
melaniab opened this issue Jan 18, 2020 · 2 comments
Open

How to make Tensorrec have stable results #154

melaniab opened this issue Jan 18, 2020 · 2 comments

Comments

@melaniab
Copy link

melaniab commented Jan 18, 2020

Hello,

I am currently using TensorRec for my master's thesis project, and have been following the MovieLens guide on getting started with the library. I am trying to test different features (embeddings) for content-based recommendations. However, the results that I have so far are not stable, meaning I get different results when I rerun the same piece of code with the same data.

For example, with the same dataset I got first

Recall at 10: Train: 0.0424 Test: 0.0407

and then later:

Recall at 10: Train: 0.0412 Test: 0.0406

How can I make it stable? I did not see anywhere in the code random_seed being set, and I'm not sure where and how can I set it.

The RecSys I use is:

content_model = tensorrec.TensorRec(
    n_components=n_features,
    item_repr_graph=tensorrec.representation_graphs.FeaturePassThroughRepresentationGraph(),
     loss_graph=tensorrec.loss_graphs.WMRBLossGraph()
)
content_model.fit(interactions=sparse_train_ratings_4plus,
                  user_features=user_indicator_features,
                  item_features=books_features,
                 n_sampled_items=int(n_items * .01))

Thank you in advance!

@jfkirk
Copy link
Owner

jfkirk commented Jan 23, 2020

Hi @melaniab -- I expect that what your seeing is because of different random seeds, as you suspected.

I haven't tried this, but you could try setting the seed directly to the TensorFlow session before creating the TensorRec object:

tf.set_random_seed(0)
content_model = tensorrec.TensorRec(.......

Let me know if that works for you.

@dkolokotronis-artefact
Copy link

Hello I am also trying to solve this issue! I tried tf.random.set_seed(1), but it didn't work. Any suggestions? thank you

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

3 participants