hidasib / GRU4Rec

GRU4Rec is the original Theano implementation of the algorithm in "Session-based Recommendations with Recurrent Neural Networks" paper, published at ICLR 2016 and its follow-up "Recurrent Neural Networks with Top-k Gains for Session-based Recommendations". The code is optimized for execution on the GPU.
Other
754 stars 223 forks source link

Is it possible to output the embedding of user/session and item vectors? #29

Closed KunlinY closed 4 years ago

KunlinY commented 5 years ago

After training, is it possible to output the embedding of session embedding and item embedding? Or could you tell me how to get those emebddings?

hidasib commented 4 years ago

You can get the item embedding fairly simply. Depending on the value of the embedding and constrained_embedding model parameters, you can have have: (a) only out item embedding in Wy (embedding=0, constrained_embedding=False) (b) in and out item embeddings in E and Wy respectively (embedding=X, constrained_embedding=False, X>0) (c) unified item embedding in Wy (embedding=0, constrained_embedding=True)

Select the variable you want to get the embedding from and get its value from the theano shared variable (e.g. Wy.get_value(borrow=False)). To match this to the item IDs in your data you must use the itemidmap variable of the model (translates item IDs from your train data to indexes).

Getting session embeddings is not supported in the public version at the moment. This functionality might be added from the internal version in the future.