Following the tutorial Recommending movies: retrieval | TensorFlow Recommenders
How do you extract the trained embeddings of a trained model?
I know you can use model.get_layer(‘sequential_##’).get_weights()[0] to output the embeddings. How do you index this to unique_user_ids/unique_movie_titles, also taking into account the +1 padding on the user_model and movie_model? Does it take the same order?
user_model = tf.keras.Sequential([
tf.keras.layers.StringLookup(
vocabulary=unique_user_ids, mask_token=None),
# We add an additional embedding to account for unknown tokens.
tf.keras.layers.Embedding(len(unique_user_ids) + 1, embedding_dimension)
])
movie_model = tf.keras.Sequential([
tf.keras.layers.StringLookup(
vocabulary=unique_movie_titles, mask_token=None),
tf.keras.layers.Embedding(len(unique_movie_titles) + 1, embedding_dimension)
])